Index: components/nacl/loader/nonsfi/irt_thread.cc |
diff --git a/components/nacl/loader/nonsfi/irt_thread.cc b/components/nacl/loader/nonsfi/irt_thread.cc |
index 3351bdc48b1dbbfee29eb063a668f6f1c7e102b6..e6303de7f8bc85aed6fef33709e3411784d92c50 100644 |
--- a/components/nacl/loader/nonsfi/irt_thread.cc |
+++ b/components/nacl/loader/nonsfi/irt_thread.cc |
@@ -9,6 +9,7 @@ |
#include "base/macros.h" |
#include "base/memory/scoped_ptr.h" |
#include "components/nacl/loader/nonsfi/irt_interfaces.h" |
+#include "native_client/src/trusted/service_runtime/nacl_signal.h" |
namespace nacl { |
namespace nonsfi { |
@@ -33,6 +34,7 @@ class ScopedPthreadAttrPtr { |
struct ThreadContext { |
void (*start_func)(); |
void* thread_ptr; |
+ void* signal_stack; |
}; |
// A thread local pointer to support nacl_irt_tls. |
@@ -45,6 +47,10 @@ void* ThreadMain(void *arg) { |
::scoped_ptr<ThreadContext> context(static_cast<ThreadContext*>(arg)); |
g_thread_ptr = context->thread_ptr; |
+ // NaClLog(4, "Registering alternate signal stack: %p\n", |
+ // context->signal_stack); |
+ NaClSignalStackRegister(context->signal_stack); |
+ |
// Release the memory of context before running start_func. |
void (*start_func)() = context->start_func; |
context.reset(); |
@@ -72,6 +78,10 @@ int IrtThreadCreate(void (*start_func)(), void* stack, void* thread_ptr) { |
::scoped_ptr<ThreadContext> context(new ThreadContext); |
context->start_func = start_func; |
context->thread_ptr = thread_ptr; |
+ if (!NaClSignalStackAllocate(&context->signal_stack)) { |
+ // NaClLog(4, "Failed to allocate alternate stack\n"); |
+ return error; |
+ } |
pthread_t tid; |
error = pthread_create(&tid, &attr, ThreadMain, context.get()); |