Skip to content

ubsan: Runtime function suppression for implicit-integer-sign-change does not work unless -fno-inline #132533

Open
@maflcko

Description

@maflcko

This happens when:

  • Using -O1 or above, without specifying -fno-inline
  • Using integer-sign-change suppressions based on function name, as opposed to file name

Steps to reproduce:

$ cat << 'EOF_CPP' > /tmp/a.cpp && cat << 'EOF_SUPP_ISAN' > /tmp/supp_isan
int fun(unsigned a) { return a; }
int main() { (void)fun(4294961650); }
EOF_CPP
implicit-integer-sign-change:fun
EOF_SUPP_ISAN
$ bld/bin/clang++ -O1 -g -std=c++11 -fsanitize=integer -o /tmp/a.exe /tmp/a.cpp && UBSAN_OPTIONS="suppressions=/tmp/supp_isan:print_stacktrace=1:halt_on_error=1:report_error_type=1" /tmp/a.exe

/tmp/a.cpp:1:30: runtime error: implicit conversion from type 'unsigned int' of value 4294961650 (32-bit, unsigned) to type 'int' changed the value to -5646 (32-bit, signed)
    #0 0x560fd5739b46 in fun(unsigned int) /tmp/a.cpp:1:30
    #1 0x560fd5739b46 in main /tmp/a.cpp:2:20
...
    #4 0x560fd570d3f4 in _start (/tmp/a.exe+0x13f4)

SUMMARY: UndefinedBehaviorSanitizer: implicit-integer-sign-change /tmp/a.cpp:1:30 

$ bld/bin/clang++ -fno-inline  -O1 -g -std=c++11 -fsanitize=integer -o /tmp/a.exe /tmp/a.cpp && UBSAN_OPTIONS="suppressions=/tmp/supp_isan:print_stacktrace=1:halt_on_error=1:report_error_type=1" /tmp/a.exe
(works)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions