sigpanic_unix.go 1010 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // 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. // +build darwin dragonfly freebsd linux netbsd openbsd solaris
  5. package runtime
  6. func signame(int32) *byte
  7. func sigpanic() {
  8. g := getg()
  9. if !canpanic(g) {
  10. gothrow("unexpected signal during runtime execution")
  11. }
  12. switch g.sig {
  13. case _SIGBUS:
  14. if g.sigcode0 == _BUS_ADRERR && g.sigcode1 < 0x1000 || g.paniconfault {
  15. panicmem()
  16. }
  17. print("unexpected fault address ", hex(g.sigcode1), "\n")
  18. gothrow("fault")
  19. case _SIGSEGV:
  20. if (g.sigcode0 == 0 || g.sigcode0 == _SEGV_MAPERR || g.sigcode0 == _SEGV_ACCERR) && g.sigcode1 < 0x1000 || g.paniconfault {
  21. panicmem()
  22. }
  23. print("unexpected fault address ", hex(g.sigcode1), "\n")
  24. gothrow("fault")
  25. case _SIGFPE:
  26. switch g.sigcode0 {
  27. case _FPE_INTDIV:
  28. panicdivide()
  29. case _FPE_INTOVF:
  30. panicoverflow()
  31. }
  32. panicfloat()
  33. }
  34. panic(errorString(gostringnocopy(signame(g.sig))))
  35. }