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

[tsan] Process SIGPROF as sync signal only if thread is alive #86343

Conversation

vitalybuka
Copy link
Collaborator

Otherwise it may crash too early.

This is followup to #85188

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 22, 2024

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Vitaly Buka (vitalybuka)

Changes

Otherwise it may crash too early.

This is followup to #85188


Full diff: https://github.com/llvm/llvm-project/pull/86343.diff

1 Files Affected:

  • (modified) compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp (+3-3)
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
index 2bebe651b994e5..810ce69663d050 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
@@ -2169,8 +2169,7 @@ static bool is_sync_signal(ThreadSignalContext *sctx, int sig,
     return false;
 #endif
   return sig == SIGSEGV || sig == SIGBUS || sig == SIGILL || sig == SIGTRAP ||
-         sig == SIGABRT || sig == SIGFPE || sig == SIGPIPE || sig == SIGSYS ||
-         sig == SIGPROF;
+         sig == SIGABRT || sig == SIGFPE || sig == SIGPIPE || sig == SIGSYS;
 }
 
 void sighandler(int sig, __sanitizer_siginfo *info, void *ctx) {
@@ -2181,7 +2180,8 @@ void sighandler(int sig, __sanitizer_siginfo *info, void *ctx) {
     return;
   }
   // Don't mess with synchronous signals.
-  const bool sync = is_sync_signal(sctx, sig, info);
+  const bool sync = is_sync_signal(sctx, sig, info) ||
+                    (sig == SIGPROF && thr->is_inited && !thr->is_dead);
   if (sync ||
       // If we are in blocking function, we can safely process it now
       // (but check if we are in a recursive interceptor,

@vitalybuka vitalybuka changed the title [tsan] Process SIGPROF as sync sygnal only if theread is alive [tsan] Process SIGPROF as sync signal only if thread is alive Mar 22, 2024
@vitalybuka vitalybuka changed the base branch from users/vitalybuka/spr/main.tsan-process-sigprof-as-sync-sygnal-only-if-theread-is-alive to main March 22, 2024 22:12
Created using spr 1.3.4
Copy link

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link

✅ With the latest revision this PR passed the Python code formatter.

@vitalybuka vitalybuka merged commit 362d263 into main Mar 22, 2024
4 checks passed
@vitalybuka vitalybuka deleted the users/vitalybuka/spr/tsan-process-sigprof-as-sync-sygnal-only-if-theread-is-alive branch March 22, 2024 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants