Blame build/build-clang/pr_set_ptracer.patch

Packit f0b94e
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
Packit f0b94e
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
Packit f0b94e
@@ -57,6 +57,14 @@
Packit f0b94e
 #include "sanitizer_mutex.h"
Packit f0b94e
 #include "sanitizer_placement_new.h"
Packit f0b94e
 
Packit f0b94e
+// Sufficiently old kernel headers don't provide this value, but we can still
Packit f0b94e
+// call prctl with it. If the runtime kernel is new enough, the prctl call will
Packit f0b94e
+// have the desired effect; if the kernel is too old, the call will error and we
Packit f0b94e
+// can ignore said error.
Packit f0b94e
+#ifndef PR_SET_PTRACER
Packit f0b94e
+#define PR_SET_PTRACER 0x59616d61
Packit f0b94e
+#endif
Packit f0b94e
+
Packit f0b94e
 // This module works by spawning a Linux task which then attaches to every
Packit f0b94e
 // thread in the caller process with ptrace. This suspends the threads, and
Packit f0b94e
 // PTRACE_GETREGS can then be used to obtain their register state. The callback
Packit f0b94e
@@ -433,9 +441,7 @@
Packit f0b94e
     ScopedSetTracerPID scoped_set_tracer_pid(tracer_pid);
Packit f0b94e
     // On some systems we have to explicitly declare that we want to be traced
Packit f0b94e
     // by the tracer thread.
Packit f0b94e
-#ifdef PR_SET_PTRACER
Packit f0b94e
     internal_prctl(PR_SET_PTRACER, tracer_pid, 0, 0, 0);
Packit f0b94e
-#endif
Packit f0b94e
     // Allow the tracer thread to start.
Packit f0b94e
     tracer_thread_argument.mutex.Unlock();
Packit f0b94e
     // NOTE: errno is shared between this thread and the tracer thread.