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

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

Issue 906041: code review 906041: runtime: turn divide by zero, nil dereference into panics (Closed)
Patch Set: code review 906041: runtime: turn divide by zero, nil dereference into panics Created 14 years, 12 months 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/linux/signals.h ('k') | src/pkg/runtime/runtime.h » ('j') | 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 "signals.h"
8 #include "os.h" 7 #include "os.h"
9 8
9 extern SigTab sigtab[];
10
10 // Linux futex. 11 // Linux futex.
11 // 12 //
12 // futexsleep(uint32 *addr, uint32 val) 13 // futexsleep(uint32 *addr, uint32 val)
13 // futexwakeup(uint32 *addr) 14 // futexwakeup(uint32 *addr)
14 // 15 //
15 // Futexsleep atomically checks if *addr == val and if so, sleeps on addr. 16 // Futexsleep atomically checks if *addr == val and if so, sleeps on addr.
16 // Futexwakeup wakes up one thread sleeping on addr. 17 // Futexwakeup wakes up one thread sleeping on addr.
17 // Futexsleep is allowed to wake up spuriously. 18 // Futexsleep is allowed to wake up spuriously.
18 19
19 enum 20 enum
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 264 }
264 265
265 // Called to initialize a new m (including the bootstrap m). 266 // Called to initialize a new m (including the bootstrap m).
266 void 267 void
267 minit(void) 268 minit(void)
268 { 269 {
269 // Initialize signal handling. 270 // Initialize signal handling.
270 m->gsignal = malg(32*1024); // OS X wants >=8K, Linux >=2K 271 m->gsignal = malg(32*1024); // OS X wants >=8K, Linux >=2K
271 signalstack(m->gsignal->stackguard, 32*1024); 272 signalstack(m->gsignal->stackguard, 32*1024);
272 } 273 }
274
275 void
276 sigpanic(void)
277 {
278 switch(g->sig) {
279 case SIGBUS:
280 if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000)
281 panicstring("invalid memory address or nil pointer deref erence");
282 break;
283 case SIGSEGV:
284 if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR) && g->sigcod e1 < 0x1000)
285 panicstring("invalid memory address or nil pointer deref erence");
286 break;
287 case SIGFPE:
288 switch(g->sigcode0) {
289 case FPE_INTDIV:
290 panicstring("integer divide by zero");
291 case FPE_INTOVF:
292 panicstring("integer overflow");
293 }
294 panicstring("floating point error");
295 }
296 panicstring(sigtab[g->sig].name);
297 }
OLDNEW
« no previous file with comments | « src/pkg/runtime/linux/signals.h ('k') | src/pkg/runtime/runtime.h » ('j') | no next file with comments »

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