[llvm] [Support] Don't re-raise signals sent from kernel (PR #145759)

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 8 13:53:06 PDT 2025


================
@@ -413,10 +413,22 @@ static void SignalHandler(int Sig, siginfo_t *Info, void *) {
     raise(Sig);
 #endif
 
-  // Signal sent from another process, do not assume that continuing the
-  // execution would re-raise it.
-  if (Info->si_pid != getpid())
+  // Signal sent from another userspace process, do not assume that continuing
+  // the execution would re-raise it.
+  if (Info->si_pid != getpid() && Info->si_pid != 0) {
+#if defined(__linux__) || defined(__ANDROID__)
+    // Re-raising a signal via `raise` loses the original siginfo. Recent
+    // versions of linux (>= 3.9) support processes sending a signal to itself
+    // with arbitrary signal information using a syscall. If this syscall is
+    // unsupported, errno will be set to EPERM and `raise` will be used instead.
+    int retval = syscall(SYS_rt_tgsigqueueinfo, getpid(), syscall(SYS_gettid),
----------------
pcc wrote:

I was imagining that we would always do this on Linux regardless of what's in Info, same as for the Chromium change. As things stand with your change I think we would still have the bug for the kernel-generated async signals because si_pid = 0.

https://github.com/llvm/llvm-project/pull/145759


More information about the llvm-commits mailing list