runtime: sigaction problem when using cgo on FreeBSD #25745
Closed
Labels
Comments
I believe that this is already fixed on tip and therefore in the upcoming 1.11 release as part of the work on #14327. I'm going to close this issue but please do comment if I turn out to be mistaken. |
Fantastic! I can confirm this is now fixed against the current tip: $ go version
go version devel +2ce295e954 Wed Jun 6 01:47:31 2018 +0000 freebsd/amd64
$ go run sigbug.go
ret=0 handler=0x44a9c0 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Likely.
What operating system and processor architecture are you using (
go env
)?What did you do?
The following simple cgo program:
Succeeds (prints a non-0 signal handler) on Darwin and Linux:
But fails (prints a 0 signal handler) on FreeBSD:
What did you expect to see?
I expected to see the signal handler that the go runtime installs.
What did you see instead?
The C
sigaction
function thinks that there is no signal handler.Investigation
I believe the reason for the "mysterious"
sigaction
behavior is that the Go runtime invokessigaction
usingSYSCALL
. However FreeBSD expects that C (and cgo) programs should use the libcsigaction
, which is "interposed" by libthr to__thr_sigaction
. Libthr maintains its own copy ofsigaction
's and overrides what the kernel returns.A likely fix for this is to do what Linux does for
sigaction
. Invoke it usingSYSCALL
if "!cgo" or use the C librarysigaction
if "cgo". Seert_sigaction
.Additional information at billziss-gh/cgofuse#18.
The text was updated successfully, but these errors were encountered: