Panic was caused by a stack smash, default cgo thread stack size was too small. My fix is to change cgo thread stack size at compile time by patching gcc_darwin_amd64.c, _cgo_sys_thread_start:
40a41,45 > #ifdef CGO_STACK_SIZE > size = CGO_STACK_SIZE; > pthread_attr_setstacksize(&attr, size); > #endif > $ CGO_CFLAGS="-DCGO_STACK_SIZE=0x200000" make There does not seem to be any other way to increase the stack size for interop threads. On Monday, October 1, 2018 at 7:53:03 PM UTC-4, pba wrote: > > I'm running into a situation where my program deadlocks due to > (apparently) a call to runtime.(*sigctxt).preparePanic which never exits > (stack below). > > The program uses cgo and passes callbacks to the C library, this > particular panic seems to be triggered when the go callback returns to the > C code. I cannot debug the C code (binary dependency). > > Any suggestions on how to make the the program crash cleanly (i.e. panic > and exit) ? > > go version go1.11 darwin/amd64 > macOS Sierra (10.12.6) > > 2359 Thread_1644947 > + 2359 _sigtramp (in libsystem_platform.dylib) + 26 [0x7fff9656cb3a] > + 2359 runtime.sigtramp (in test) + 51 [0x4065fe3] > + 2359 runtime.sigtrampgo (in test) + 544 [0x4049000] > + 2359 runtime.sighandler (in test) + 1788 [0x404866c] > + 2359 runtime.(*sigctxt).preparePanic (in test) + 172 > [0x40475fc] > > Thanks > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.