Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: src/native_client/src/trusted/service_runtime/posix/nacl_signal.c

Issue 3857001: Work around sigaltstack() bug on Mac OS X when unregistering a signal stack (Closed)
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698