[GM-help] Deadlock (busy loop) on panic/SIGSEGV case in Go API user code
Swiss army knife of image processing
Brought to you by:
bfriesen
From: Kagami H. <ka...@ge...> - 2018-03-16 19:38:14
|
Hello. With the recent SA_ONSTACK fix I get deadlock in this minimal Go example code: ``` package main /* #cgo pkg-config: GraphicsMagick #include <magick/api.h> */ import "C" import "fmt" type A struct { b *B } type B struct { c int } func main() { C.InitializeMagick(nil) a := A{nil} fmt.Println(a.b.c) } ``` Without SA_ONSTACK fix I get this output which is not normal Go panic too: https://gist.github.com/f0f4a1b0e65021050f020b3d88b06aaa Normal panic should look like this (comment "C.InitializeMagick(nil)" line): ``` $ go run gm.go panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x483937] goroutine 1 [running]: main.main() /home/kagami/gm.go:13 +0x27 exit status 2 ``` Probably it's caused by violating some rules described at: https://golang.org/pkg/os/signal/#hdr-Go_programs_that_use_cgo_or_SWIG E.g. SA_RESTART and signal mask bits. Maybe it would be better to not redefine "oldact"? I.e. make first sigaction call with act=NULL and don't re-set it in case if it's non-empty. It would be even better to not set any handlers for API users at all, unless requested, but as you said before it might cause ABI change... |