mitchellh / panicwrap

panicwrap is a Go library for catching and handling panics in Go applications.
https://gist.github.com/mitchellh/90029601268e59a29e64e55bab1c5bdc
MIT License
443 stars 69 forks source link

failed to track some other panic msgs #29

Open LinkShen opened 3 years ago

LinkShen commented 3 years ago

Hi, recently I found that some specific panic type will be ignored. As the code shown below:

func trackPanic(r io.Reader, w io.Writer, dur time.Duration, result chan<- string) {
    ...
    panicHeaders := [][]byte{
        []byte("panic:"),
        []byte("fatal error: fault"),
    }
    ...
}

panicwrap only deal with these two kinds panic msgs. But I met: "fatal error: concurrent map iteration and map write" these kinds of panic will be ignored.

powerman commented 2 years ago

Another one: fatal error: sync: unlock of unlocked mutex.

powerman commented 2 years ago

Complete list of fatal error: for Go 1.19:

$ rg 'fatal[(]"' | sed 's/.*fatal("\(.*\)")/\1/' | sort -u
all goroutines are asleep - deadlock!
AllThreadsSyscall6 results differ between threads; runtime corrupted
concurrent map iteration and map write
concurrent map read and map write
concurrent map writes
go of nil func value
no goroutines (main called runtime.Goexit) - deadlock!
sync: RUnlock of unlocked RWMutex
sync: unlock of unlocked mutex
sync: Unlock of unlocked RWMutex
powerman commented 2 years ago

Well, actually it's not a complete list. There are a several hundreds throw("…") calls which also output as a fatal error:, e.g.:

$ ulimit -H -v 100000; ./app
fatal error: failed to reserve page summary memory

runtime stack:
runtime.throw({0xe06faa?, 0x7ffc50bc35a0?})
    /usr/lib/go/src/runtime/panic.go:1047 +0x5d fp=0x7ffc50bc3550 sp=0x7ffc50bc3520 pc=0x43b59d
runtime.(*pageAlloc).sysInit(0x16a65f0)
    /usr/lib/go/src/runtime/mpagealloc_64bit.go:82 +0x18d fp=0x7ffc50bc35d8 sp=0x7ffc50bc3550 pc=0x43030d
runtime.(*pageAlloc).init(0x16a65f0, 0x16a65e0, 0x0?)
    /usr/lib/go/src/runtime/mpagealloc.go:324 +0x70 fp=0x7ffc50bc3600 sp=0x7ffc50bc35d8 pc=0x42df50
runtime.(*mheap).init(0x16a65e0)
    /usr/lib/go/src/runtime/mheap.go:721 +0x13f fp=0x7ffc50bc3638 sp=0x7ffc50bc3600 pc=0x42b37f
runtime.mallocinit()
    /usr/lib/go/src/runtime/malloc.go:407 +0xb2 fp=0x7ffc50bc3660 sp=0x7ffc50bc3638 pc=0x40e1f2
runtime.schedinit()
    /usr/lib/go/src/runtime/proc.go:693 +0xab fp=0x7ffc50bc36c0 sp=0x7ffc50bc3660 pc=0x43ef6b
runtime.rt0_go()
    /usr/lib/go/src/runtime/asm_amd64.s:345 +0x189 fp=0x7ffc50bc36c8 sp=0x7ffc50bc36c0 pc=0x46d669