Index: runtime/vm/os_thread_linux.cc |
diff --git a/runtime/vm/os_thread_linux.cc b/runtime/vm/os_thread_linux.cc |
index a0e68f1870e5b3222039a3b5467aea05d29cd214..ffcd2e67368d4c7bc4dc53acc956b07a8250fc5b 100644 |
--- a/runtime/vm/os_thread_linux.cc |
+++ b/runtime/vm/os_thread_linux.cc |
@@ -3,6 +3,8 @@ |
// BSD-style license that can be found in the LICENSE file. |
#include "platform/globals.h" // NOLINT |
+#include "platform/signal_blocker.h" // NOLINT |
+ |
#if defined(TARGET_OS_LINUX) |
#include "vm/os_thread.h" |
@@ -85,6 +87,21 @@ class ThreadStartData { |
}; |
+// Spawned threads inherit their spawner's signal mask. We sometimes spawn |
+// threads for running Dart code from a thread that is blocking SIGPROF. |
+// This function explicitly unblocks SIGPROF so the profiler continues to |
+// sample this thread. |
+static void UnblockSIGPROF() { |
+ sigset_t set; |
+ sigemptyset(&set); |
+ sigaddset(&set, SIGPROF); |
+ int r = pthread_sigmask(SIG_UNBLOCK, &set, NULL); |
+ USE(r); |
+ ASSERT(r == 0); |
+ ASSERT(!CHECK_IS_BLOCKING(SIGPROF)); |
+} |
+ |
+ |
// Dispatch to the thread start function provided by the caller. This trampoline |
// is used to ensure that the thread is properly destroyed if the thread just |
// exits. |
@@ -101,7 +118,7 @@ static void* ThreadStart(void* data_ptr) { |
if (thread != NULL) { |
OSThread::SetCurrent(thread); |
thread->set_name(name); |
- |
+ UnblockSIGPROF(); |
// Call the supplied thread start function handing it its parameters. |
function(parameter); |
} |