Closed
Description
This program should run forever. It crashes quickly, because GoroutineProfile is using the wrong pc/sp combination for the traceback if the corresponding goroutine has just come out of a system call. The only workaround is not to call GoroutineProfile. Possible #go121 candidate. package main import ( "runtime" "syscall" ) func main() { runtime.GOMAXPROCS(200) for i := 0; i < 10; i++ { go func() { for { syscall.Close(-1) } }() } stk := make([]runtime.StackRecord, 1000) for n := 0;; n++ { _, ok := runtime.GoroutineProfile(stk) if !ok { panic("GoroutineProfile refused") } if n&(n-1) == 0 { println(n) } } } panic: invalid memory address or nil pointer dereference fatal error: panic during gc [signal 0xb code=0x1 addr=0x0 pc=0x1a7f5] goroutine 1 [running]: runtime.throw(0x6b1ac) /Users/rsc/g/go/src/pkg/runtime/panic.c:462 +0x69 fp=0x2210248d40 runtime.panicstring(0x6b5b9) /Users/rsc/g/go/src/pkg/runtime/panic.c:477 +0x8d fp=0x2210248d68 runtime.sigpanic() /Users/rsc/g/go/src/pkg/runtime/os_darwin.c:450 +0x16a fp=0x2210248d80 runtime.gentraceback(0x7850, 0x0, 0x0, 0x2100d8ea0, 0x0, ...) /Users/rsc/g/go/src/pkg/runtime/traceback_x86.c:101 +0x745 fp=0x2210248e40 saveg(0x7850, 0x0, 0x2100d8ea0, 0x210148600) /Users/rsc/rscgo/src/pkg/runtime/mprof.goc:531 +0x76 fp=0x2210248ea0 runtime.GoroutineProfile(0x210148000, 0x3e8, 0x3e8, 0xc, 0x301) /Users/rsc/rscgo/src/pkg/runtime/mprof.goc:559 +0x148 fp=0x2210248ee8 main.main() /Users/rsc/x.go:19 +0xbd fp=0x2210248f48 runtime.main() /Users/rsc/g/go/src/pkg/runtime/proc.c:220 +0x11f fp=0x2210248fa0 runtime.goexit() /Users/rsc/g/go/src/pkg/runtime/proc.c:1394 fp=0x2210248fa8