inim4 / googletest

Automatically exported from code.google.com/p/googletest
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

SEGV on 4 or more test cases with Address Sanitizer #487

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I link my executable against -fsanitize=address so that I can run it with 
LLVM's Address Sanitizer.  When I define more than 3 test cases, I will 
invariably get a SEGV when gtest gets to the 4th test case.  I tested that this 
holds true even if all of the tests I define across these 4 or more test cases 
are empty stubs.  

Attached is a more complete build and test run output.  Here is the relevant 
address sanitizer error:
ASAN:SIGSEGV
=================================================================
==10221==ERROR: AddressSanitizer: SEGV on unknown address 0x603000085dd0 (pc 
0x000000642a5e bp 0x7fff30ba3bd0 sp 0x7fff30ba3ba0 T0)
    #0 0x642a5d in testing::internal::UnitTestImpl::GetMutableTestCase(int) (/media/sf_local/aalgocpp/bin/algorithmscpp+0x642a5d)
    #1 0x63618f in testing::internal::UnitTestImpl::RunAllTests() (/media/sf_local/aalgocpp/bin/algorithmscpp+0x63618f)
    #2 0x64c2c2 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (/media/sf_local/aalgocpp/bin/algorithmscpp+0x64c2c2)
    #3 0x642f56 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (/media/sf_local/aalgocpp/bin/algorithmscpp+0x642f56)
    #4 0x635d82 in testing::UnitTest::Run() (/media/sf_local/aalgocpp/bin/algorithmscpp+0x635d82)
    #5 0x51be08 in RUN_ALL_TESTS() /media/sf_local/aalgocpp/bii/deps/google/gtest/include/gtest/gtest.h:2288:10
    #6 0x51bc80 in main /media/sf_local/aalgocpp/src/main.cpp:6:12
    #7 0x7fde3473a78c in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2178c)
    #8 0x46e244 in _start (/media/sf_local/aalgocpp/bin/algorithmscpp+0x46e244)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV ??:0 
testing::internal::UnitTestImpl::GetMutableTestCase(int)
==10221==ABORTING

Original issue reported on code.google.com by vake...@gmail.com on 19 Apr 2015 at 11:25

Attachments:

GoogleCodeExporter commented 9 years ago
I'm running the tests on Ubuntu 12.04 with the current release of LLVM and 
Clang 3.6.0 from LLVM's official downloads.  I'm using Google Test 1.7.0.

Original comment by vake...@gmail.com on 19 Apr 2015 at 11:30

GoogleCodeExporter commented 9 years ago
Unfortunately, I seem to get the same result when all tests are in a single 
test case.  See the attached output.  I'm unsure what the cause is.  

Original comment by vake...@gmail.com on 19 Apr 2015 at 11:35

Attachments:

GoogleCodeExporter commented 9 years ago
It looks like this may have actually been a configuration problem on my end.  I 
had my source files linking against -fsanitize=address, but I was not passing 
the parameter to the build of gtest.  When I pass -fsanitize=address to the 
gtest build as well, I don't get this AddressSanitizer error.  It looks like 
it's just necessary for all of the dependencies to be sanitized in order for it 
to correctly understand the memory.  

I believe this can be closed.

Original comment by vake...@gmail.com on 20 Apr 2015 at 1:13

GoogleCodeExporter commented 9 years ago
I'm glad you found the problem.
Just for the record, gtest has been tested with many of the sanitizer 
configurations, including Address Sanitizer, Memory Sanitizer and Thread 
Sanitizer.

Original comment by sbe...@google.com on 20 Apr 2015 at 3:04

GoogleCodeExporter commented 9 years ago

Original comment by sbe...@google.com on 20 Apr 2015 at 3:05