From: Tobias Brunner Date: Tue, 29 Nov 2022 15:51:06 +0000 (+0100) Subject: thread: Exclude thread_main() from AddressSanitizer X-Git-Tag: 5.9.9rc1~33 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=42165f81bcf3062d215ae600604f940bb6876008;p=thirdparty%2Fstrongswan.git thread: Exclude thread_main() from AddressSanitizer With GCC 11.3 AddressSanitizer causes the following crash when a thread is cancelled (e.g. in the test_condvar_cancel test): ==84365==AddressSanitizer CHECK failed: ../../../../src/libsanitizer/asan/asan_thread.cpp:367 "((ptr[0] == kCurrentStackFrameMagic)) != (0)" (0x0, 0x0) #0 0x7ff0801b2988 in AsanCheckFailed ../../../../src/libsanitizer/asan/asan_rtl.cpp:74 #1 0x7ff0801d330e in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) ../../../../src/libsanitizer/sanitizer_common/sanitizer_termination.cpp:78 #2 0x7ff0801b810c in __asan::AsanThread::GetStackFrameAccessByAddr(unsigned long, __asan::AsanThread::StackFrameAccess*) ../../../../src/libsanitizer/asan/asan_thread.cpp:367 #3 0x7ff080122e9b in __asan::GetStackAddressInformation(unsigned long, unsigned long, __asan::StackAddressDescription*) ../../../../src/libsanitizer/asan/asan_descriptions.cpp:203 #4 0x7ff0801242d8 in __asan::AddressDescription::AddressDescription(unsigned long, unsigned long, bool) ../../../../src/libsanitizer/asan/asan_descriptions.cpp:455 #5 0x7ff0801242d8 in __asan::AddressDescription::AddressDescription(unsigned long, unsigned long, bool) ../../../../src/libsanitizer/asan/asan_descriptions.cpp:439 #6 0x7ff080126a84 in __asan::ErrorGeneric::ErrorGeneric(unsigned int, unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long) ../../../../src/libsanitizer/asan/asan_errors.cpp:389 #7 0x7ff0801b1fa5 in __asan::ReportGenericError(unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long, unsigned int, bool) ../../../../src/libsanitizer/asan/asan_report.cpp:476 #8 0x7ff080148fe8 in __interceptor_sigaltstack ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:9986 #9 0x7ff0801af473 in __asan::PlatformUnpoisonStacks() ../../../../src/libsanitizer/asan/asan_posix.cpp:44 #10 0x7ff0801b500c in __asan_handle_no_return ../../../../src/libsanitizer/asan/asan_rtl.cpp:612 #11 0x7ff07fe04d50 in thread_main /media/sf_scratch/src/libstrongswan/threading/thread.c:321 #12 0x7ff07d7d4b42 in start_thread nptl/pthread_create.c:442 #13 0x7ff07d8669ff (/lib/x86_64-linux-gnu/libc.so.6+0x1269ff) --- diff --git a/src/libstrongswan/threading/thread.c b/src/libstrongswan/threading/thread.c index b4ff4a1dad..d132c940aa 100644 --- a/src/libstrongswan/threading/thread.c +++ b/src/libstrongswan/threading/thread.c @@ -306,7 +306,11 @@ static void thread_cleanup(private_thread_t *this) /** * Main function wrapper for threads. + * + * Excluded from AddressSanitizer because some newer versions have an issue that + * causes an "AddressSanitizer CHECK failed" error for cancelled threads. */ +ADDRESS_SANITIZER_EXCLUDE static void *thread_main(private_thread_t *this) { void *res;