Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1139)

Side by Side Diff: src/pkg/runtime/linux/thread.c

Issue 4230044: code review 4230044: runtime: fix signal stack bug (Closed)
Patch Set: diff -r b0e4832734b3 https://go.googlecode.com/hg Created 14 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/runtime/freebsd/thread.c ('k') | 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 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 #include "runtime.h" 5 #include "runtime.h"
6 #include "defs.h" 6 #include "defs.h"
7 #include "os.h" 7 #include "os.h"
8 #include "stack.h"
8 9
9 extern SigTab runtime·sigtab[]; 10 extern SigTab runtime·sigtab[];
10 11
11 // Linux futex. 12 // Linux futex.
12 // 13 //
13 // futexsleep(uint32 *addr, uint32 val) 14 // futexsleep(uint32 *addr, uint32 val)
14 // futexwakeup(uint32 *addr) 15 // futexwakeup(uint32 *addr)
15 // 16 //
16 // Futexsleep atomically checks if *addr == val and if so, sleeps on addr. 17 // Futexsleep atomically checks if *addr == val and if so, sleeps on addr.
17 // Futexwakeup wakes up one thread sleeping on addr. 18 // Futexwakeup wakes up one thread sleeping on addr.
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 { 268 {
268 runtime·goenvs_unix(); 269 runtime·goenvs_unix();
269 } 270 }
270 271
271 // Called to initialize a new m (including the bootstrap m). 272 // Called to initialize a new m (including the bootstrap m).
272 void 273 void
273 runtime·minit(void) 274 runtime·minit(void)
274 { 275 {
275 // Initialize signal handling. 276 // Initialize signal handling.
276 m->gsignal = runtime·malg(32*1024); // OS X wants >=8K, Linux >=2K 277 m->gsignal = runtime·malg(32*1024); // OS X wants >=8K, Linux >=2K
277 » runtime·signalstack(m->gsignal->stackguard, 32*1024); 278 » runtime·signalstack(m->gsignal->stackguard - StackGuard, 32*1024);
278 } 279 }
279 280
280 void 281 void
281 runtime·sigpanic(void) 282 runtime·sigpanic(void)
282 { 283 {
283 switch(g->sig) { 284 switch(g->sig) {
284 case SIGBUS: 285 case SIGBUS:
285 if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000) 286 if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000)
286 runtime·panicstring("invalid memory address or nil point er dereference"); 287 runtime·panicstring("invalid memory address or nil point er dereference");
287 runtime·printf("unexpected fault address %p\n", g->sigcode1); 288 runtime·printf("unexpected fault address %p\n", g->sigcode1);
288 runtime·throw("fault"); 289 runtime·throw("fault");
289 case SIGSEGV: 290 case SIGSEGV:
290 if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR || g->sigcode 0 == SEGV_ACCERR) && g->sigcode1 < 0x1000) 291 if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR || g->sigcode 0 == SEGV_ACCERR) && g->sigcode1 < 0x1000)
291 runtime·panicstring("invalid memory address or nil point er dereference"); 292 runtime·panicstring("invalid memory address or nil point er dereference");
292 runtime·printf("unexpected fault address %p\n", g->sigcode1); 293 runtime·printf("unexpected fault address %p\n", g->sigcode1);
293 runtime·throw("fault"); 294 runtime·throw("fault");
294 case SIGFPE: 295 case SIGFPE:
295 switch(g->sigcode0) { 296 switch(g->sigcode0) {
296 case FPE_INTDIV: 297 case FPE_INTDIV:
297 runtime·panicstring("integer divide by zero"); 298 runtime·panicstring("integer divide by zero");
298 case FPE_INTOVF: 299 case FPE_INTOVF:
299 runtime·panicstring("integer overflow"); 300 runtime·panicstring("integer overflow");
300 } 301 }
301 runtime·panicstring("floating point error"); 302 runtime·panicstring("floating point error");
302 } 303 }
303 runtime·panicstring(runtime·sigtab[g->sig].name); 304 runtime·panicstring(runtime·sigtab[g->sig].name);
304 } 305 }
OLDNEW
« no previous file with comments | « src/pkg/runtime/freebsd/thread.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b