-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Closed
Labels
Description
by sqweek:
What steps will reproduce the problem? 1. Make cgo calls to a C library that uses pthreads 2. Make the library call pthread_cancel on one of its threads I created a small test case, available at https://github.com/sqweek/signal32-bug What is the expected output? The thread is cancelled and the program continues running. What do you see instead? The program crashes with message: runtime: signal received on thread not created by Go: signal 32 Which compiler are you using (5g, 6g, 8g, gccgo)? cgo/6g Which operating system are you using? Linux 3.12.0-1 Which version are you using? (run 'go version') Reproduced on both: go version go1.1.2 linux/amd64 go version devel +f4d1cb8d9a91 Thu Sep 19 22:34:33 2013 +1000 linux/amd64 Please provide any additional information below. According to http://man7.org/linux/man-pages/man3/pthread_cancel.3.html#NOTES pthread_cancel() is implemented via signals on linux. I tried changing signal 32's flags to 0 in pkg/runtime/signals_linux.h which fixes the crash, but the program then hangs in pthread_join(). gdb reports the cancelled thread still exists and is blocked (ie, "finish" never got anywhere) in __libc_disable_asynccancel(): Thread 5 (Thread 0x7ffff6010700 (LWP 12137)): #0 0x00007ffff7905aff in __libc_disable_asynccancel () from /usr/lib/libc.so.6 #1 0x00007ffff78cab49 in nanosleep () from /usr/lib/libc.so.6 #2 0x00007ffff78ca9d4 in sleep () from /usr/lib/libc.so.6 #3 0x000000000040100e in threadfunc (dummy=<optimized out>) at /d/code/go/src/github.com/sqweek/signal32-bug/thread.c:10 #4 0x00007ffff7bc70a2 in start_thread () from /usr/lib/libpthread.so.0 #5 0x00007ffff78f949d in clone () from /usr/lib/libc.so.6