Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to disable a UBSAN rule on std lib? #82500

Open
tony-go opened this issue Feb 21, 2024 · 0 comments
Open

How to disable a UBSAN rule on std lib? #82500

tony-go opened this issue Feb 21, 2024 · 0 comments
Labels
compiler-rt:ubsan Undefined behavior sanitizer question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

Comments

@tony-go
Copy link

tony-go commented Feb 21, 2024

Hi Everyone 👋🏼

I experience this error with UBSAN:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/__functional/hash.h:107:40: runtime error: left shift of 7308895138221481827 by 48 places cannot be represented in type 'unsigned long'

So, I'd like to exclude the shift rule for this specific (as I don't have control over it).

So, as the documentation mention, I tried to pass a suppression file as UBSAN_OPTIONS:

shift-base:hash.h
shift-exponent:hash.h

It did not exclude the error, my first attempt was:

shift:hash.h

Then the compiler spits an error:

UndefinedBehaviorSanitizer: failed to parse suppressions

I probably should have noticed something. It's probably the path, tho.


Full log:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/__functional/hash.h:107:40: runtime error: left shift of 7308895138221481827 by 48 places cannot be represented in type 'unsigned long'
    #0 0x104d94f5c in std::__1::__murmur2_or_cityhash<unsigned long, 64ul>::__rotate_by_at_least_1(unsigned long, int) hash.h:107
    #1 0x104d93094 in std::__1::__murmur2_or_cityhash<unsigned long, 64ul>::__hash_len_0_to_16(char const*, unsigned long) hash.h:132
    #2 0x104d91cf0 in std::__1::__murmur2_or_cityhash<unsigned long, 64ul>::operator()(void const*, unsigned long) hash.h:226
    #3 0x104d91c50 in unsigned long std::__1::__do_string_hash[abi:v15006]<char const*>(char const*, char const*) char_traits.h:920
    #4 0x104d903f0 in std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) const string:4565
    #5 0x104d9ac9c in std::__1::__hash_const_iterator<std::__1::__hash_node<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, void*>*> std::__1::__hash_table<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>::find<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) const __hash_table:2333
    #6 0x104d9aac8 in unsigned long std::__1::__hash_table<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>::__count_unique<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) const __hash_table:2515
    #7 0x104d9a93c in std::__1::unordered_set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>::count[abi:v15006](std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) const unordered_set:798
    #8 0x104d1973c in testing::internal::(anonymous namespace)::UnitTestFilter::MatchesName(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) const gtest.cc:781
    #9 0x104d6cac4 in testing::internal::UnitTestImpl::GetTestSuite(char const*, char const*, void (*)(), void (*)()) gtest.cc:5766
    #10 0x104d37dc0 in testing::internal::UnitTestImpl::AddTestInfo(void (*)(), void (*)(), testing::TestInfo*) gtest-internal-inl.h:690
    #11 0x104d37810 in testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*) gtest.cc:2771
    #12 0x104cd8e90 in __cxx_global_var_init engine_binding_test.cc:32
    #13 0x104cd9dc8 in _GLOBAL__sub_I_engine_binding_test.cc engine_binding_test.cc
    #14 0x18157c1d4  (<unknown module>)
    #15 0x1815bde90  (<unknown module>)
    #16 0x1815b11a0  (<unknown module>)
    #17 0x18155c2d4  (<unknown module>)
    #18 0x1815b01c8  (<unknown module>)
    #19 0x1815bd954  (<unknown module>)
    #20 0x181578858  (<unknown module>)
    #21 0x181578c0c  (<unknown module>)
    #22 0x18157c260  (<unknown module>)
    #23 0x181578d8c  (<unknown module>)
    #24 0x18159c980  (<unknown module>)
    #25 0x1815612cc  (<unknown module>)
    #26 0x18155fe14  (<unknown module>)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/__functional/hash.h:107:40 in
@tony-go tony-go changed the title How to disable a rule on std lib? How to disable a UBSAN rule on std lib? Feb 21, 2024
@EugeneZelenko EugeneZelenko added question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! compiler-rt:ubsan Undefined behavior sanitizer and removed new issue labels Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler-rt:ubsan Undefined behavior sanitizer question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Projects
None yet
Development

No branches or pull requests

2 participants