Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <errno.h> | 5 #include <errno.h> |
| 6 #include <pthread.h> | 6 #include <pthread.h> |
| 7 #include <signal.h> | 7 #include <signal.h> |
| 8 | 8 |
| 9 #include "components/nacl/loader/nonsfi/irt_interfaces.h" | 9 #include "components/nacl/loader/nonsfi/irt_interfaces.h" |
| 10 #include "native_client/src/include/nacl_macros.h" | 10 #include "native_client/src/include/nacl_macros.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 // native_client/src/trusted/service_runtime/sys_exception.c | 22 // native_client/src/trusted/service_runtime/sys_exception.c |
| 23 | 23 |
| 24 // Crash signals to handle. The differences from SFI NaCl are that | 24 // Crash signals to handle. The differences from SFI NaCl are that |
| 25 // NonSFI NaCl does not use NACL_THREAD_SUSPEND_SIGNAL (==SIGUSR1), | 25 // NonSFI NaCl does not use NACL_THREAD_SUSPEND_SIGNAL (==SIGUSR1), |
| 26 // and SIGSYS is reserved for seccomp-bpf. | 26 // and SIGSYS is reserved for seccomp-bpf. |
| 27 const int kSignals[] = { | 27 const int kSignals[] = { |
| 28 #if !defined(__mips__) | 28 #if !defined(__mips__) |
| 29 // This signal does not exist on MIPS. | 29 // This signal does not exist on MIPS. |
| 30 SIGSTKFLT, | 30 SIGSTKFLT, |
| 31 #endif | 31 #endif |
| 32 SIGINT, SIGQUIT, SIGILL, SIGTRAP, SIGBUS, SIGFPE, SIGSEGV, | 32 SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGTRAP, SIGBUS, SIGFPE, SIGSEGV, SIGTERM, |
|
Mark Seaborn
2015/06/10 18:53:12
Do you need to add SIGHUP and SIGTERM, or is it ju
rickyz (no longer on Chrome)
2015/06/10 22:42:34
I want to add any signals that might be sent to th
| |
| 33 // Handle SIGABRT in case someone sends it asynchronously using kill(). | 33 // Handle SIGABRT in case someone sends it asynchronously using kill(). |
| 34 SIGABRT | 34 SIGABRT |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; | 37 pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; |
| 38 NaClExceptionHandler signal_handler_function_pointer = NULL; | 38 NaClExceptionHandler signal_handler_function_pointer = NULL; |
| 39 | 39 |
| 40 // Signal handler, responsible for calling the registered handler. | 40 // Signal handler, responsible for calling the registered handler. |
| 41 void SignalCatch(int sig, siginfo_t* info, void* uc) { | 41 void SignalCatch(int sig, siginfo_t* info, void* uc) { |
| 42 if (signal_handler_function_pointer) { | 42 if (signal_handler_function_pointer) { |
| 43 NaClSignalContext signal_context; | 43 NaClSignalContext signal_context; |
| 44 NaClSignalContextFromHandler(&signal_context, uc); | 44 NaClSignalContextFromHandler(&signal_context, uc); |
| 45 NaClExceptionFrame exception_frame; | 45 NaClExceptionFrame exception_frame; |
| 46 NaClSignalSetUpExceptionFrame(&exception_frame, | 46 NaClSignalSetUpExceptionFrame(&exception_frame, |
| 47 &signal_context, | 47 &signal_context, |
| 48 0 /* context_user_addr, | 48 0 /* context_user_addr, |
| 49 not useful for NonSFI NaCl. */); | 49 not useful for NonSFI NaCl. */); |
| 50 signal_handler_function_pointer(&exception_frame.context); | 50 signal_handler_function_pointer(&exception_frame.context); |
| 51 } | 51 } |
| 52 _exit(-1); | 52 _exit(-sig); |
|
rickyz (no longer on Chrome)
2015/06/10 01:31:43
I didn't want to change this file a ton in this CL
Mark Seaborn
2015/06/10 18:53:12
Yes, that's all intentional.
This implements the
rickyz (no longer on Chrome)
2015/06/10 22:42:34
Ah, in that case, is it incorrect to run the excep
Mark Seaborn
2015/06/15 22:29:04
Yes, it's technically incorrect, although it might
rickyz (no longer on Chrome)
2015/06/15 23:23:51
Ah, thank you for the detailed explanation. In tha
| |
| 53 } | 53 } |
| 54 | 54 |
| 55 int IrtExceptionHandler(NaClExceptionHandler handler, | 55 int IrtExceptionHandler(NaClExceptionHandler handler, |
| 56 NaClExceptionHandler* old_handler) { | 56 NaClExceptionHandler* old_handler) { |
| 57 pthread_mutex_lock(&mutex); | 57 pthread_mutex_lock(&mutex); |
| 58 if (old_handler) | 58 if (old_handler) |
| 59 *old_handler = signal_handler_function_pointer; | 59 *old_handler = signal_handler_function_pointer; |
| 60 signal_handler_function_pointer = handler; | 60 signal_handler_function_pointer = handler; |
| 61 pthread_mutex_unlock(&mutex); | 61 pthread_mutex_unlock(&mutex); |
| 62 return 0; | 62 return 0; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 | 101 |
| 102 // Install all handlers. | 102 // Install all handlers. |
| 103 for (a = 0; a < NACL_ARRAY_SIZE(kSignals); a++) { | 103 for (a = 0; a < NACL_ARRAY_SIZE(kSignals); a++) { |
| 104 if (sigaction(kSignals[a], &sa, NULL) != 0) | 104 if (sigaction(kSignals[a], &sa, NULL) != 0) |
| 105 NaClLog(LOG_FATAL, "sigaction to register signals failed.\n"); | 105 NaClLog(LOG_FATAL, "sigaction to register signals failed.\n"); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 } // namespace nonsfi | 109 } // namespace nonsfi |
| 110 } // namespace nacl | 110 } // namespace nacl |
| OLD | NEW |