eranpeer / FakeIt

C++ mocking made easy. A simple yet very expressive, headers only library for c++ mocking.
MIT License
1.22k stars 170 forks source link

Undefined sanitizer issue #304

Closed MBkkt closed 1 year ago

MBkkt commented 1 year ago

https://github.com/arangodb/arangodb/blob/devel/tests/Sharding/ShardDistributionReporterTest.cpp#L136

Maybe we are use it wrong? Cannot understand, both classes have virtual dtor. Also we use old version of fakeit, I tried new but nothing changed.

clang is 14.0.6

cmake .. -DUSE_ENTERPRISE=On -DUSE_MAINTAINER_MODE=On -DUSE_FAILURE_TESTS=On -DUSE_JEMALLOC=Off -DUSE_IPO=Off -DCMAKE_C_FLAGS="-fsanitize=address,undefined,float-divide-by-zero,leak -fno-sanitize=alignment" -DCMAKE_CXX_FLAGS="-fsanitize=address,undefined,float-divide-by-zero,leak -fno-sanitize=alignment" -DBASE_LD_FLAGS="-fuse-ld=lld -Wl,--build-id -fno-stack-protector" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DUSE_FAIL_ON_WARNINGS=On
➜  arangodb git:(devel) ✗ ./build_aulsan/bin/arangodbtests --gtest_filter="*ShardDistributionReporterTest*"
Note: Google Test filter = *ShardDistributionReporterTest*
[==========] Running 8 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 8 tests from ShardDistributionReporterTest
[ RUN      ] ShardDistributionReporterTest.a_healthy_instance_a_single_collection_of_three_shards_and_three_replicas
/home/mbkkt/projects/arangodb/3rdParty/fakeit-gtest/fakeit.hpp:5278:47: runtime error: member call on address 0x7ffe801a0560 which does not point to an object of type 'arangodb::ClusterInfo'
0x7ffe801a0560: note: object is of type 'fakeit::VirtualOffsetSelector'
 fe 7f 00 00  40 ae 0a 28 a5 55 00 00  07 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  80 04 1a 80
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'fakeit::VirtualOffsetSelector'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/mbkkt/projects/arangodb/3rdParty/fakeit-gtest/fakeit.hpp:5278:47 in 
/home/mbkkt/projects/arangodb/3rdParty/fakeit-gtest/fakeit.hpp:5278:47: runtime error: member call on address 0x7ffe801a0560 which does not point to an object of type 'arangodb::CollectionInfoCurrent'
0x7ffe801a0560: note: object is of type 'fakeit::VirtualOffsetSelector'
 fe 7f 00 00  40 ae 0a 28 a5 55 00 00  04 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  80 04 1a 80
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'fakeit::VirtualOffsetSelector'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/mbkkt/projects/arangodb/3rdParty/fakeit-gtest/fakeit.hpp:5278:47 in 
MBkkt commented 1 year ago

https://github.com/eranpeer/FakeIt/pull/261

FranckRJ commented 1 year ago

As you seen in the PR you linked there are some issues with sanitizers and fakeit as of now. I'll try fix some of them for the next release.

MBkkt commented 1 year ago

Cool thanks, it's same issue as in 261 pr

FranckRJ commented 1 year ago

It's fixed by #318 which will be in FakeIt 2.4.0.