[PATCH] D39717: Always use prctl(PR_SET_PTRACER)

Mike Hommey via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 7 14:10:48 PST 2017

glandium updated this revision to Diff 121983.
glandium added a comment.

Updated wording.



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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39717.121983.patch
Type: text/x-patch
Size: 1364 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171107/e475430e/attachment-0001.bin>

More information about the cfe-commits mailing list