-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: Uncaught panics in callbacks from foreign threads result in SIGSEGV #5657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
right. it's about panic in Go callback functions, the following is a simpler reproducer: // callback.go package main // void runThread(void); import "C" //export Callback func Callback() { panic("callback panic") } func main() { C.runThread() select {} } // callback.c #include <pthread.h> #include "_cgo_export.h" void *thread_main(void *unused) { Callback(); } void runThread() { pthread_t p; pthread_create(&p, NULL, thread_main, NULL); pthread_join(p, 0); } Output: $ ./test-panic SIGSEGV: segmentation violation PC=0x1be6d |
g% ./callback SIGSEGV: segmentation violation PC=0x401c2dd runtime.lessstack() /Users/rsc/g/go/src/pkg/runtime/asm_amd64.s:289 +0x1d goroutine 3 [running]: reflect.call(0x4059438, 0x421ef68) /Users/rsc/g/go/src/pkg/runtime/asm_amd64.s:235 fp=0x421ee58 runtime.panic(0x4021dc0, 0xc21000a010) /Users/rsc/g/go/src/pkg/runtime/panic.c:234 +0x51 fp=0x421ee98 main.Callback() /tmp/callback/x.go:9 +0x55 fp=0x421eec8 ----- stack segment boundary ----- runtime.panic(0x4021dc0, 0xc21000a010) /Users/rsc/g/go/src/pkg/runtime/panic.c:247 +0x106 fp=0x421ee98 main.Callback() /tmp/callback/x.go:9 +0x55 fp=0x421eec8 ----- stack segment boundary ----- runtime.cgocallbackg1() /Users/rsc/g/go/src/pkg/runtime/cgocall.c:311 +0xbf fp=0x421ef80 runtime.cgocallbackg() /Users/rsc/g/go/src/pkg/runtime/cgocall.c:281 +0x84 fp=0x421ef90 runtime.cgocallback_gofunc(0x0, 0x0, 0x0) /Users/rsc/g/go/src/pkg/runtime/asm_amd64.s:620 +0x67 fp=0x421efa0 runtime.goexit() /Users/rsc/g/go/src/pkg/runtime/proc.c:1332 fp=0x421efa8 goroutine 1 [syscall]: main._Cfunc_runThread(0x4010ed3) _/tmp/callback/_obj/_cgo_defun.c:43 +0x31 main.main() /tmp/callback/x.go:11 +0x1a goroutine 4 [syscall]: runtime.goexit() /Users/rsc/g/go/src/pkg/runtime/proc.c:1332 rax 0xc2100016c0 rbx 0xc210012800 rcx 0x0 rdx 0x4059438 rdi 0xb0103e00 rsi 0xc210012840 rbp 0xc2100016c0 rsp 0x0 r8 0x421e000 r9 0x0 r10 0x21ec3fd6 r11 0x66a2222a r12 0x2f83c0f0befae r13 0x2fa72c37b97f0 r14 0x1315b87c3ec35a00 r15 0x4000f20 rip 0x401c2dd rflags 0x10216 cs 0x2b fs 0x0 gs 0x0 g% Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Attachments:
The text was updated successfully, but these errors were encountered: