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

ASAN SEGV's on mixed C++-C unit googletest #1601

Open
chaiken opened this issue Dec 26, 2022 · 0 comments
Open

ASAN SEGV's on mixed C++-C unit googletest #1601

chaiken opened this issue Dec 26, 2022 · 0 comments

Comments

@chaiken
Copy link

chaiken commented Dec 26, 2022

The code at chaiken/util-scripts@94cb15c triggers a SEGV:

./cpumask_test
Running main() from /home/alison/gitsrc/googletest/googletest/src/gtest_main.cc
[==========] Running 3 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 3 tests from SimpleCpuMaskTest
[ RUN ] SimpleCpuMaskTest.ParseSingleCore
[ OK ] SimpleCpuMaskTest.ParseSingleCore (0 ms)
[ RUN ] SimpleCpuMaskTest.BadCore
[ OK ] SimpleCpuMaskTest.BadCore (27 ms)
[ RUN ] SimpleCpuMaskTest.ParseRange
AddressSanitizer:DEADLYSIGNAL

==775030==ERROR: AddressSanitizer: SEGV on unknown address 0x55b4116964f0 (pc 0x7f0ce722d357 bp 0x000000000002 sp 0x7ffd497047f0 T0)
==775030==The signal is caused by a WRITE memory access.
#0 0x7f0ce722d357 in bool __sanitizer::atomic_compare_exchange_strong<__sanitizer::atomic_uint8_t>(__sanitizer::atomic_uint8_t volatile*, __sanitizer::atomic_uint8_t::Type*, __sanitizer::atomic_uint8_t::Type, __sanitizer::memory_order) ../../../../src/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h:80
#1 0x7f0ce722d357 in __asan::Allocator::AtomicallySetQuarantineFlagIfAllocated(__asan::AsanChunk*, void*, __sanitizer::BufferedStackTrace*) ../../../../src/libsanitizer/asan/asan_allocator.cpp:620
#2 0x7f0ce722d357 in __asan::Allocator::Deallocate(void*, unsigned long, unsigned long, __sanitizer::BufferedStackTrace*, __asan::AllocType) ../../../../src/libsanitizer/asan/asan_allocator.cpp:696
#3 0x7f0ce72ba39d in operator delete(void*, unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:164
#4 0x55b411644db6 in std::_Sp_counted_ptr<char const*, (__gnu_cxx::_Lock_policy)2>::_M_dispose() /usr/include/c++/12/bits/shared_ptr_base.h:428
#5 0x55b41163539f in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() /usr/include/c++/12/bits/shared_ptr_base.h:346
#6 0x55b41163841b in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count() /usr/include/c++/12/bits/shared_ptr_base.h:1071
#7 0x55b411637d35 in std::__shared_ptr<char const, (__gnu_cxx::_Lock_policy)2>::
__shared_ptr() /usr/include/c++/12/bits/shared_ptr_base.h:1524
#8 0x55b411637da3 in std::shared_ptr::~shared_ptr() /usr/include/c++/12/bits/shared_ptr.h:175
#9 0x55b411633e4b in SimpleCpuMaskTest_ParseRange_Test::TestBody() /home/alison/gitsrc/util-scripts/cpumask_testsuite.cc:50
#10 0x55b411680e24 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::)(), char const) (/home/alison/gitsrc/util-scripts/cpumask_test+0x83e24)
#11 0x55b41167a0d6 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::)(), char const) (/home/alison/gitsrc/util-scripts/cpumask_test+0x7d0d6)
#12 0x55b411657b5f in testing::Test::Run() (/home/alison/gitsrc/util-scripts/cpumask_test+0x5ab5f)
#13 0x55b411658575 in testing::TestInfo::Run() (/home/alison/gitsrc/util-scripts/cpumask_test+0x5b575)
#14 0x55b411658ddb in testing::TestSuite::Run() (/home/alison/gitsrc/util-scripts/cpumask_test+0x5bddb)
#15 0x55b4116686c8 in testing::internal::UnitTestImpl::RunAllTests() (/home/alison/gitsrc/util-scripts/cpumask_test+0x6b6c8)
#16 0x55b411681d5e in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::)(), char const) (/home/alison/gitsrc/util-scripts/cpumask_test+0x84d5e)
#17 0x55b41167b112 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::)(), char const) (/home/alison/gitsrc/util-scripts/cpumask_test+0x7e112)
#18 0x55b411666f01 in testing::UnitTest::Run() (/home/alison/gitsrc/util-scripts/cpumask_test+0x69f01)
#19 0x55b41169414a in RUN_ALL_TESTS() (/home/alison/gitsrc/util-scripts/cpumask_test+0x9714a)
#20 0x55b4116940cf in main (/home/alison/gitsrc/util-scripts/cpumask_test+0x970cf)
#21 0x7f0ce7046189 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
#22 0x7f0ce7046244 in __libc_start_main_impl ../csu/libc-start.c:381
#23 0x55b41162e090 in _start (/home/alison/gitsrc/util-scripts/cpumask_test+0x31090)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV ../../../../src/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h:80 in bool __sanitizer::atomic_compare_exchange_strong<__sanitizer::atomic_uint8_t>(__sanitizer::atomic_uint8_t volatile*, __sanitizer::atomic_uint8_t::Type*, __sanitizer::atomic_uint8_t::Type, __sanitizer::memory_order)
==775030==ABORTING

To reproduce:

  1. git clone git@github.com:chaiken/util-scripts.git
  2. git am 0001-reproduce-SEGV.patch
  3. make cpumask_test && ./cpumask_test

The g++ version is 12.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant