blob: 7bf2c15409170ac27f014684078494e2ed8ee3e6 [file] [log] [blame]
Russ Coxc81a0ed2014-09-08 14:05:23 -04001// Copyright 2014 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// +build darwin dragonfly freebsd linux netbsd openbsd solaris
6
7package runtime
8
Russ Coxc81a0ed2014-09-08 14:05:23 -04009func sigpanic() {
10 g := getg()
11 if !canpanic(g) {
12 gothrow("unexpected signal during runtime execution")
13 }
14
15 switch g.sig {
16 case _SIGBUS:
17 if g.sigcode0 == _BUS_ADRERR && g.sigcode1 < 0x1000 || g.paniconfault {
18 panicmem()
19 }
20 print("unexpected fault address ", hex(g.sigcode1), "\n")
21 gothrow("fault")
22 case _SIGSEGV:
23 if (g.sigcode0 == 0 || g.sigcode0 == _SEGV_MAPERR || g.sigcode0 == _SEGV_ACCERR) && g.sigcode1 < 0x1000 || g.paniconfault {
24 panicmem()
25 }
26 print("unexpected fault address ", hex(g.sigcode1), "\n")
27 gothrow("fault")
28 case _SIGFPE:
29 switch g.sigcode0 {
30 case _FPE_INTDIV:
31 panicdivide()
32 case _FPE_INTOVF:
33 panicoverflow()
34 }
35 panicfloat()
36 }
Russ Cox2d917c02014-11-11 17:05:55 -050037
38 if g.sig >= uint32(len(sigtable)) {
39 // can't happen: we looked up g.sig in sigtable to decide to call sigpanic
40 gothrow("unexpected signal value")
41 }
42 panic(errorString(sigtable[g.sig].name))
Russ Coxc81a0ed2014-09-08 14:05:23 -040043}