You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
UndefinedBehaviorSanitizer is a very handy tool that helped me find and troubleshoot many bugs in C++ projects. Unfortunately hippomocks appear to be incompatible with it.
Either clang++ -std=c++20 -fsanitize=undefined main.cpp
of g++ -std=c++20 -fsanitize=undefined main.cpp
Expected
a.out prints mocked.txt when executed
Got
clang:
UndefinedBehaviorSanitizer:DEADLYSIGNAL
==42734==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x000000002021 (pc 0x7f75b7e9ac97 bp
0x55d79bb42f80 sp 0x7ffc4c2cc900 T42734)
==42734==The signal is caused by a READ memory access.
#00x7f75b7e9ac97 in __dynamic_cast (/lib/x86_64-linux-gnu/libstdc++.so.6+0xacc97) (BuildId: e37fe1a
879783838de78cbc8c80621fa685d58a2)
#10x55d79bae5f4b in __ubsan::checkDynamicType(void*, void*, unsignedlong) (/home/cdda/tmp/a.out+0x
4af4b) (BuildId: 35ce505127e6a2099c0cd91fb29ee70fe2925749)
#20x55d79bae5092 in HandleDynamicTypeCacheMiss(__ubsan::DynamicTypeCacheMissData*, unsignedlong, u
nsigned long, __ubsan::ReportOptions) ubsan_handlers_cxx.cpp.o
#30x55d79bae505d in __ubsan_handle_dynamic_type_cache_miss (/home/cdda/tmp/a.out+0x4a05d) (BuildId:
35ce505127e6a2099c0cd91fb29ee70fe2925749)
#40x55d79bafa9cd in void HippoMocks::MockRepository::BasicRegisterExpect<CSystemUtils>(HippoMocks::
mock<CSystemUtils>*, int, int, void (HippoMocks::base_mock::*)(), int) (/home/cdda/tmp/a.out+0x5f9cd) (B
uildId: 35ce505127e6a2099c0cd91fb29ee70fe2925749)
#50x55d79bae6a3d in HippoMocks::TCall<char*, HippoMocks::NullType, HippoMocks::NullType, HippoMocks
::NullType, HippoMocks::NullType, HippoMocks::NullType, HippoMocks::NullType, HippoMocks::NullType, Hipp
oMocks::NullType, HippoMocks::NullType, HippoMocks::NullType, HippoMocks::NullType, HippoMocks::NullType
, HippoMocks::NullType, HippoMocks::NullType, HippoMocks::NullType, HippoMocks::NullType>& HippoMocks::M
ockRepository::RegisterExpect_<16, CSystemUtils, char*, CSystemUtils>(CSystemUtils*, char* (CSystemUtils
::*)(), HippoMocks::RegistrationType, charconst*, charconst*, unsignedlong) (/home/cdda/tmp/a.out+0x4
ba3d) (BuildId: 35ce505127e6a2099c0cd91fb29ee70fe2925749)
#60x55d79bae62e1 in main (/home/cdda/tmp/a.out+0x4b2e1) (BuildId: 35ce505127e6a2099c0cd91fb29ee70fe
2925749)
#70x7f75b7ae8d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#80x7f75b7ae8e3f in __libc_start_main csu/../csu/libc-start.c:392:3
#90x55d79babc664 in _start (/home/cdda/tmp/a.out+0x21664) (BuildId: 35ce505127e6a2099c0cd91fb29ee70
fe2925749)
UndefinedBehaviorSanitizer can not provide additional info.
SUMMARY: UndefinedBehaviorSanitizer: SEGV (/lib/x86_64-linux-gnu/libstdc++.so.6+0xacc97) (BuildId: e37fe
1a879783838de78cbc8c80621fa685d58a2) in __dynamic_cast
==42734==ABORTING
gcc:
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7e31c97 in __dynamic_cast () from /lib/x86_64-linux-gnu/libstdc++.so.6
(gdb) bt
#00x00007ffff7e31c97 in __dynamic_cast () from /lib/x86_64-linux-gnu/libstdc++.so.6
#10x00007ffff76795ab in __ubsan::checkDynamicType (Object=Object@entry=0x5555555d0eb0,
Type=0x5555555a6aa0 <typeinfo for CSystemUtils>, Hash=4824472795596714896)
at ../../../../src/libsanitizer/ubsan/ubsan_type_hash_itanium.cpp:232
#20x00007ffff76780d6 in HandleDynamicTypeCacheMiss (Data=0x5555555afec0, Pointer=93824992743088, Hash=<optimized out>, Opts=...)
at ../../../../src/libsanitizer/ubsan/ubsan_handlers_cxx.cpp:36
#30x00007ffff767878f in __ubsan::__ubsan_handle_dynamic_type_cache_miss (Data=<optimized out>, Pointer=<optimized out>,
Hash=<optimized out>) at ../../../../src/libsanitizer/ubsan/ubsan_handlers_cxx.cpp:87
#40x0000555555575964 in main ()
(gdb)
UndefinedBehaviorSanitizer is a very handy tool that helped me find and troubleshoot many bugs in C++ projects. Unfortunately hippomocks appear to be incompatible with it.
main.cpp
Compile
clang++ -std=c++20 -fsanitize=undefined main.cpp
g++ -std=c++20 -fsanitize=undefined main.cpp
Expected
a.out prints
mocked.txt
when executedGot
clang:
gcc:
Versions Tested
master branch (10960d0)
v5.0 (dca4725)
The text was updated successfully, but these errors were encountered: