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..b7f5c9a7e03c7dd708f630acc3f652260c4c13f4 100644 |
--- a/components/nacl/loader/nonsfi/irt_thread.cc |
+++ b/components/nacl/loader/nonsfi/irt_thread.cc |
@@ -6,9 +6,11 @@ |
#include <pthread.h> |
#include <stdlib.h> |
+#include "base/logging.h" |
#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 +35,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 +48,9 @@ void* ThreadMain(void *arg) { |
::scoped_ptr<ThreadContext> context(static_cast<ThreadContext*>(arg)); |
g_thread_ptr = context->thread_ptr; |
+ DVLOG(4) << "Registering alternate signal stack: " << context->signal_stack; |
+ NaClSignalStackRegister(context->signal_stack); |
Mark Seaborn
2014/04/23 03:49:50
This probably doesn't work: the seccomp sandbox wi
Junichi Uekawa
2014/04/23 07:56:15
I was wondering why my tests are succeeding and I
|
+ |
// 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)) { |
+ DVLOG(1) << "Failed to allocate alternate stack\n"; |
+ return error; |
+ } |
pthread_t tid; |
error = pthread_create(&tid, &attr, ThreadMain, context.get()); |