Bug 1409267 - Patch compiler-rt to always use prctl(PR_SET_PTRACER). r=froydnj
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 07 Nov 2017 15:07:30 +0900
changeset 443892 b2dd86a66344a2717f5cae026ac47247be525712
parent 443891 44f0f3508112bb23ab23fb1c90ab062768ee959c
child 443893 836cb7a4cc24cfaa73fa9470d35dec538d725d11
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1409267
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1409267 - Patch compiler-rt to always use prctl(PR_SET_PTRACER). r=froydnj
build/build-clang/clang-4-linux64.json
build/build-clang/clang-5-linux64.json
build/build-clang/pr_set_ptracer.patch
--- a/build/build-clang/clang-4-linux64.json
+++ b/build/build-clang/clang-4-linux64.json
@@ -11,11 +11,12 @@
     "libcxxabi_repo": "https://llvm.org/svn/llvm-project/libcxxabi/tags/RELEASE_401/final",
     "python_path": "/usr/bin/python2.7",
     "gcc_dir": "/builds/worker/workspace/build/src/gcc",
     "cc": "/builds/worker/workspace/build/src/gcc/bin/gcc",
     "cxx": "/builds/worker/workspace/build/src/gcc/bin/g++",
     "as": "/builds/worker/workspace/build/src/gcc/bin/gcc",
     "patches": [
       "llvm-debug-frame.patch",
-      "hide-gcda-profiling-symbols.patch"
+      "hide-gcda-profiling-symbols.patch",
+      "pr_set_ptracer.patch"
     ]
 }
--- a/build/build-clang/clang-5-linux64.json
+++ b/build/build-clang/clang-5-linux64.json
@@ -11,11 +11,12 @@
     "libcxxabi_repo": "https://llvm.org/svn/llvm-project/libcxxabi/tags/RELEASE_500/final",
     "python_path": "/usr/bin/python2.7",
     "gcc_dir": "/builds/worker/workspace/build/src/gcc",
     "cc": "/builds/worker/workspace/build/src/gcc/bin/gcc",
     "cxx": "/builds/worker/workspace/build/src/gcc/bin/g++",
     "as": "/builds/worker/workspace/build/src/gcc/bin/gcc",
     "patches": [
       "llvm-debug-frame-for-5.patch",
-      "r313872.patch"
+      "r313872.patch",
+      "pr_set_ptracer.patch"
     ]
 }
new file mode 100644
--- /dev/null
+++ b/build/build-clang/pr_set_ptracer.patch
@@ -0,0 +1,27 @@
+--- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
++++ b/compiler-rt/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.
++#ifndef PR_SET_PTRACER
++#define PR_SET_PTRACER 0x59616d61
++#endif
++
+ // 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.
+-#ifdef PR_SET_PTRACER
+     internal_prctl(PR_SET_PTRACER, tracer_pid, 0, 0, 0);
+-#endif
+     // Allow the tracer thread to start.
+     tracer_thread_argument.mutex.Unlock();
+     // NOTE: errno is shared between this thread and the tracer thread.