| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 The Native Client Authors. All rights reserved. | 2 * Copyright 2010 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can | 3 * Use of this source code is governed by a BSD-style license that can |
| 4 * be found in the LICENSE file. | 4 * be found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <signal.h> | 8 #include <signal.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <sys/mman.h> | 10 #include <sys/mman.h> |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 } | 139 } |
| 140 | 140 |
| 141 void NaClSignalStackUnregister(void) { | 141 void NaClSignalStackUnregister(void) { |
| 142 /* | 142 /* |
| 143 * Unregister the signal stack in case a fault occurs between the | 143 * Unregister the signal stack in case a fault occurs between the |
| 144 * thread deallocating the signal stack and exiting. Such a fault | 144 * thread deallocating the signal stack and exiting. Such a fault |
| 145 * could be unsafe if the address space were reallocated before the | 145 * could be unsafe if the address space were reallocated before the |
| 146 * fault, although that is unlikely. | 146 * fault, although that is unlikely. |
| 147 */ | 147 */ |
| 148 stack_t st; | 148 stack_t st; |
| 149 #if NACL_OSX |
| 150 /* |
| 151 * This is a workaround for a bug in Mac OS X's libc, in which new |
| 152 * versions of the sigaltstack() wrapper return ENOMEM if ss_size is |
| 153 * less than MINSIGSTKSZ, even when ss_size should be ignored |
| 154 * because we are unregistering the signal stack. |
| 155 * See http://code.google.com/p/nativeclient/issues/detail?id=1053 |
| 156 */ |
| 157 st.ss_size = MINSIGSTKSZ; |
| 158 #else |
| 149 st.ss_size = 0; | 159 st.ss_size = 0; |
| 160 #endif |
| 150 st.ss_sp = NULL; | 161 st.ss_sp = NULL; |
| 151 st.ss_flags = SS_DISABLE; | 162 st.ss_flags = SS_DISABLE; |
| 152 if (sigaltstack(&st, NULL) != 0) { | 163 if (sigaltstack(&st, NULL) != 0) { |
| 153 NaClLog(LOG_FATAL, "Failed to unregister signal stack\n"); | 164 NaClLog(LOG_FATAL, "Failed to unregister signal stack\n"); |
| 154 } | 165 } |
| 155 } | 166 } |
| 156 | 167 |
| 157 | 168 |
| 158 static void ExceptionCatch(int sig, siginfo_t *info, void *uc) { | 169 static void ExceptionCatch(int sig, siginfo_t *info, void *uc) { |
| 159 int untrusted = 0; | 170 int untrusted = 0; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 int a; | 256 int a; |
| 246 | 257 |
| 247 /* Remove all handlers */ | 258 /* Remove all handlers */ |
| 248 for (a = 0; a < SIGNAL_COUNT; a++) { | 259 for (a = 0; a < SIGNAL_COUNT; a++) { |
| 249 if (sigaction(s_Signals[a], &s_OldActions[a], NULL) != 0) { | 260 if (sigaction(s_Signals[a], &s_OldActions[a], NULL) != 0) { |
| 250 NaClLog(LOG_FATAL, "Failed to unregister handler for %d.\n\tERR:%s\n", | 261 NaClLog(LOG_FATAL, "Failed to unregister handler for %d.\n\tERR:%s\n", |
| 251 s_Signals[a], strerror(errno)); | 262 s_Signals[a], strerror(errno)); |
| 252 } | 263 } |
| 253 } | 264 } |
| 254 } | 265 } |
| OLD | NEW |