[ASan] Disable InstallAtForkHandler on Linux/sparc64#108542
Merged
Conversation
When SPARC Asan testing is enabled by PR llvm#107405, many Linux/sparc64 tests just hang like ``` #0 0xf7ae8e90 in syscall () from /usr/lib32/libc.so.6 #1 0x701065e8 in __sanitizer::FutexWait(__sanitizer::atomic_uint32_t*, unsigned int) () at compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:766 llvm#2 0x70107c90 in Wait () at compiler-rt/lib/sanitizer_common/sanitizer_mutex.cpp:35 llvm#3 0x700f7cac in Lock () at compiler-rt/lib/asan/../sanitizer_common/sanitizer_mutex.h:196 llvm#4 Lock () at compiler-rt/lib/asan/../sanitizer_common/sanitizer_thread_registry.h:98 llvm#5 LockThreads () at compiler-rt/lib/asan/asan_thread.cpp:489 llvm#6 0x700e9c8c in __asan::BeforeFork() () at compiler-rt/lib/asan/asan_posix.cpp:157 llvm#7 0xf7ac83f4 in ?? () from /usr/lib32/libc.so.6 Backtrace stopped: previous frame identical to this frame (corrupt stack?) ``` It turns out that this happens in tests using `internal_fork` (e.g. invoking `llvm-symbolizer`): unlike most other Linux targets, which use `clone`, Linux/sparc64 has to use `__fork` instead. While `clone` doesn't trigger `pthread_atfork` handlers, `__fork` obviously does, causing the hang. To avoid this, this patch disables `InstallAtForkHandler` and lets the ASan tests run to completion. Tested on `sparc64-unknown-linux-gnu`.
Member
|
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Rainer Orth (rorth) ChangesWhen SPARC Asan testing is enabled by PR #107405, many Linux/sparc64 tests just hang like It turns out that this happens in tests using To avoid this, this patch disables Tested on Full diff: https://github.com/llvm/llvm-project/pull/108542.diff 1 Files Affected:
diff --git a/compiler-rt/lib/asan/asan_posix.cpp b/compiler-rt/lib/asan/asan_posix.cpp
index 76564538bd5d77..c42c0472592b78 100644
--- a/compiler-rt/lib/asan/asan_posix.cpp
+++ b/compiler-rt/lib/asan/asan_posix.cpp
@@ -171,7 +171,11 @@ static void AfterFork(bool fork_child) {
}
void InstallAtForkHandler() {
-# if SANITIZER_SOLARIS || SANITIZER_NETBSD || SANITIZER_APPLE
+# if SANITIZER_SOLARIS || SANITIZER_NETBSD || SANITIZER_APPLE || \
+ (SANITIZER_LINUX && SANITIZER_SPARC)
+ // While other Linux targets use clone in internal_fork which doesn't
+ // trigger pthread_atfork handlers, Linux/sparc64 uses __fork, causing a
+ // hang.
return; // FIXME: Implement FutexWait.
# endif
pthread_atfork(
|
vitalybuka
approved these changes
Sep 14, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When SPARC Asan testing is enabled by PR #107405, many Linux/sparc64 tests just hang like
It turns out that this happens in tests using
internal_fork(e.g. invokingllvm-symbolizer): unlike most other Linux targets, which useclone, Linux/sparc64 has to use__forkinstead. Whileclonedoesn't triggerpthread_atforkhandlers,__forkobviously does, causing the hang.To avoid this, this patch disables
InstallAtForkHandlerand lets the ASan tests run to completion.Tested on
sparc64-unknown-linux-gnu.