Source File
panic.go
Belonging Package
runtime
package runtime
import (
)
throw()
func ( int, int) {
panicCheck1(getcallerpc(), "index out of range")
panic(boundsError{x: int64(), signed: true, y: , code: boundsIndex})
}
func ( uint, int) {
panicCheck1(getcallerpc(), "index out of range")
panic(boundsError{x: int64(), signed: false, y: , code: boundsIndex})
}
func ( int, int) {
panicCheck1(getcallerpc(), "slice bounds out of range")
panic(boundsError{x: int64(), signed: true, y: , code: boundsSliceAlen})
}
func ( uint, int) {
panicCheck1(getcallerpc(), "slice bounds out of range")
panic(boundsError{x: int64(), signed: false, y: , code: boundsSliceAlen})
}
func ( int, int) {
panicCheck1(getcallerpc(), "slice bounds out of range")
panic(boundsError{x: int64(), signed: true, y: , code: boundsSliceAcap})
}
func ( uint, int) {
panicCheck1(getcallerpc(), "slice bounds out of range")
panic(boundsError{x: int64(), signed: false, y: , code: boundsSliceAcap})
}
func ( int, int) {
panicCheck1(getcallerpc(), "slice bounds out of range")
panic(boundsError{x: int64(), signed: true, y: , code: boundsSliceB})
}
func ( uint, int) {
panicCheck1(getcallerpc(), "slice bounds out of range")
panic(boundsError{x: int64(), signed: false, y: , code: boundsSliceB})
}
func ( int, int) {
panicCheck1(getcallerpc(), "slice bounds out of range")
panic(boundsError{x: int64(), signed: true, y: , code: boundsSlice3Alen})
}
func ( uint, int) {
panicCheck1(getcallerpc(), "slice bounds out of range")
panic(boundsError{x: int64(), signed: false, y: , code: boundsSlice3Alen})
}
func ( int, int) {
panicCheck1(getcallerpc(), "slice bounds out of range")
panic(boundsError{x: int64(), signed: true, y: , code: boundsSlice3Acap})
}
func ( uint, int) {
panicCheck1(getcallerpc(), "slice bounds out of range")
panic(boundsError{x: int64(), signed: false, y: , code: boundsSlice3Acap})
}
func ( int, int) {
panicCheck1(getcallerpc(), "slice bounds out of range")
panic(boundsError{x: int64(), signed: true, y: , code: boundsSlice3B})
}
func ( uint, int) {
panicCheck1(getcallerpc(), "slice bounds out of range")
panic(boundsError{x: int64(), signed: false, y: , code: boundsSlice3B})
}
func ( int, int) {
panicCheck1(getcallerpc(), "slice bounds out of range")
panic(boundsError{x: int64(), signed: true, y: , code: boundsSlice3C})
}
func ( uint, int) {
panicCheck1(getcallerpc(), "slice bounds out of range")
panic(boundsError{x: int64(), signed: false, y: , code: boundsSlice3C})
}
func ( int, int)
func ( uint, int)
func ( int, int)
func ( uint, int)
func ( int, int)
func ( uint, int)
func ( int, int)
func ( uint, int)
func ( int, int)
func ( uint, int)
func ( int, int)
func ( uint, int)
func ( int, int)
func ( uint, int)
func ( int, int)
func ( uint, int)
var shiftError = error(errorString("negative shift amount"))
func () {
panicCheck1(getcallerpc(), "negative shift amount")
panic(shiftError)
}
var divideError = error(errorString("integer divide by zero"))
func () {
panicCheck2("integer divide by zero")
panic(divideError)
}
var overflowError = error(errorString("integer overflow"))
func () {
panicCheck2("integer overflow")
panic(overflowError)
}
var floatError = error(errorString("floating point error"))
func () {
panicCheck2("floating point error")
panic(floatError)
}
var memoryError = error(errorString("invalid memory address or nil pointer dereference"))
func () {
panicCheck2("invalid memory address or nil pointer dereference")
panic(memoryError)
}
func ( uintptr) {
panicCheck2("invalid memory address or nil pointer dereference")
panic(errorAddressString{msg: "invalid memory address or nil pointer dereference", addr: })
}
throw("defer on system stack")
}
}
throw("defer on system stack")
}
const (
deferHeaderSize = unsafe.Sizeof(_defer{})
minDeferAlloc = (deferHeaderSize + 15) &^ 15
minDeferArgs = minDeferAlloc - deferHeaderSize
)
func ( uintptr) uintptr {
if <= minDeferArgs {
return 0
}
return ( - minDeferArgs + 15) / 16
}
func ( uintptr) uintptr {
if <= minDeferArgs {
return minDeferAlloc
}
return deferHeaderSize +
}
func () {
var [len(p{}.deferpool)]int32
for := range {
[] = -1
}
for := uintptr(0); ; ++ {
:= deferclass()
if >= uintptr(len()) {
break
}
:= roundupsize(totaldefersize())
if [] < 0 {
[] = int32()
continue
}
if [] != int32() {
print("bad defer size class: i=", , " siz=", , " defersc=", , "\n")
throw("bad defer size class")
}
}
}
systemstack(func() {
lock(&sched.deferlock)
for len(.deferpool[]) < cap(.deferpool[])/2 && sched.deferpool[] != nil {
:= sched.deferpool[]
sched.deferpool[] = .link
.link = nil
.deferpool[] = append(.deferpool[], )
}
unlock(&sched.deferlock)
})
}
if := len(.deferpool[]); > 0 {
= .deferpool[][-1]
.deferpool[][-1] = nil
.deferpool[] = .deferpool[][:-1]
}
}
systemstack(func() {
:= roundupsize(totaldefersize(uintptr()))
= (*_defer)(mallocgc(, deferType, true))
})
}
.siz =
.heap = true
return
}
systemstack(func() {
var , *_defer
for len(.deferpool[]) > cap(.deferpool[])/2 {
:= len(.deferpool[])
:= .deferpool[][-1]
.deferpool[][-1] = nil
.deferpool[] = .deferpool[][:-1]
if == nil {
=
} else {
.link =
}
=
}
lock(&sched.deferlock)
.link = sched.deferpool[]
sched.deferpool[] =
unlock(&sched.deferlock)
})
}
throw("freedefer with d._panic != nil")
}
throw("freedefer with d.fn != nil")
}
switch .siz {
:= getg()
var _panic
.goexit = true
.link = ._panic
._panic = (*_panic)(noescape(unsafe.Pointer(&)))
addOneOpenDeferFrame(, getcallerpc(), unsafe.Pointer(getcallersp()))
for {
:= ._defer
if == nil {
break
}
if .started {
if ._panic != nil {
._panic.aborted = true
._panic = nil
}
if !.openDefer {
.fn = nil
._defer = .link
freedefer()
continue
}
}
.started = true
._panic = (*_panic)(noescape(unsafe.Pointer(&)))
if .openDefer {
:= runOpenDeferFrame(, )
throw("unfinished open-coded defers in Goexit")
}
addOneOpenDeferFrame(, getcallerpc(), unsafe.Pointer(getcallersp()))
} else {
addOneOpenDeferFrame(, 0, nil)
}
} else {
}
goexit1()
}
_, = readvarintUnsafe()
, := readvarintUnsafe()
, := readvarintUnsafe()
:= *(*uint8)(unsafe.Pointer(.varp - uintptr()))
var , , uint32
, = readvarintUnsafe()
, = readvarintUnsafe()
, = readvarintUnsafe()
if &(1<<) == 0 {
for := uint32(0); < ; ++ {
_, = readvarintUnsafe()
_, = readvarintUnsafe()
_, = readvarintUnsafe()
}
continue
}
:= *(**funcval)(unsafe.Pointer(.varp - uintptr()))
.fn =
for := uint32(0); < ; ++ {
var , , uint32
, = readvarintUnsafe()
, = readvarintUnsafe()
, = readvarintUnsafe()
memmove(unsafe.Pointer(uintptr()+uintptr()),
unsafe.Pointer(.varp-uintptr()),
uintptr())
}
= &^ (1 << )
*(*uint8)(unsafe.Pointer(.varp - uintptr())) =
:= ._panic
reflectcallSave(, unsafe.Pointer(), , )
if != nil && .aborted {
break
}
func ( interface{}) {
:= getg()
if .m.curg != {
print("panic: ")
printany()
print("\n")
throw("panic on system stack")
}
if .m.mallocing != 0 {
print("panic: ")
printany()
print("\n")
throw("panic during malloc")
}
if .m.preemptoff != "" {
print("panic: ")
printany()
print("\n")
print("preempt off reason: ")
print(.m.preemptoff)
print("\n")
throw("panic during preemptoff")
}
if .m.locks != 0 {
print("panic: ")
printany()
print("\n")
throw("panic holding locks")
}
var _panic
.arg =
.link = ._panic
._panic = (*_panic)(noescape(unsafe.Pointer(&)))
atomic.Xadd(&runningPanicDefers, 1)
addOneOpenDeferFrame(, getcallerpc(), unsafe.Pointer(getcallersp()))
for {
:= ._defer
if == nil {
break
}
preprintpanics(._panic)
fatalpanic(._panic) // should not return
*(*int)(nil) = 0 // not reached
}
systemstack(func() {
print("fatal error: ", , "\n")
})
:= getg()
if .m.throwing == 0 {
.m.throwing = 1
}
fatalthrow()
*(*int)(nil) = 0 // not reached
}
func () {
:= getcallerpc()
:= getcallersp()
systemstack(func() {
startpanic_m()
func ( *_panic) {
:= getcallerpc()
:= getcallersp()
:= getg()
systemstack(func() {
atomic.Xadd(&runningPanicDefers, -1)
printpanics()
}
= dopanic_m(, , )
})
crash()
}
systemstack(func() {
exit(2)
})
*(*int)(nil) = 0 // not reached
}
.m.dying = 1
atomic.Xadd(&panicking, 1)
lock(&paniclk)
if debug.schedtrace > 0 || debug.scheddetail > 0 {
schedtrace(true)
}
freezetheworld()
return true
exit(5)
return false // Need to return something.
}
}
var didothers bool
var deadlock mutex
func ( *g, , uintptr) bool {
if .sig != 0 {
:= signame(.sig)
if != "" {
print("[signal ", )
} else {
print("[signal ", hex(.sig))
}
print(" code=", hex(.sigcode0), " addr=", hex(.sigcode1), " pc=", hex(.sigpc), "]\n")
}
, , := gotraceback()
:= getg()
if > 0 {
if != .m.curg {
= true
}
if != .m.g0 {
print("\n")
goroutineheader()
traceback(, , 0, )
} else if >= 2 || .m.throwing > 0 {
print("\nruntime stack:\n")
traceback(, , 0, )
}
if !didothers && {
didothers = true
tracebackothers()
}
}
unlock(&paniclk)
lock(&deadlock)
lock(&deadlock)
}
printDebugLog()
return
}
return false
return true
}
return false
return true
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |