go: runtime: musl libc setxid/setgroups signals clobber stacks / do not use SA_ONSTACK
This is a follow up to #39343 where I already briefly mentioned this problem. This issue is probably related to musl libc I can reliably reproduce it on Alpine Linux which uses musl.
What version of Go are you using (go version
)?
$ go version go version go1.14.3 linux/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/soeren/.cache/go-build" GOENV="/home/soeren/.config/go/env" GOEXE="" GOFLAGS="-buildmode=pie" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/soeren/src/go" GOPRIVATE="" GOPROXY="direct" GOROOT="/usr/lib/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build802004994=/tmp/go-build -gno-record-gcc-switches"
What did you do?
Started the TestCrossPackageTests
from misc/cgo/test/pkg_test.go
:
misc/cgo/test$ go test -run TestCrossPackageTests
What did you expect to see?
A successful test run.
What did you see instead?
An error message:
--- FAIL: TestCrossPackageTests (1.95s)
pkg_test.go:67: go test: exit status 1
--- FAIL: Test9400 (0.00s)
issue9400_linux.go:55: entry 804 of test pattern is wrong; 0x7fc60b3b0cf4 != 0x123456789abcdef
FAIL
exit status 1
FAIL cgotest 0.005s
FAIL
exit status 1
FAIL misc/cgo/test 1.958s
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 1
- Comments: 29 (10 by maintainers)
Commits related to this issue
- Ignore test on vinyl From: https://github.com/golang/go/issues/39857 This test always fails on musl, because certain things behave differently to glibc. So... sod it, ignore the test — committed to vinyl-linux/vin-packages-stable by jspc 3 years ago
- all: disable tests that fail on Alpine These changes are enough to pass all.bash using the disabled linux-amd64-alpine builder via debugnewvm. For #19938. For #39857. Change-Id: I7d160612259c77764b... — committed to golang/go by rsc 2 years ago
- all: disable tests that fail on Alpine These changes are enough to pass all.bash using the disabled linux-amd64-alpine builder via debugnewvm. For #19938. For #39857. Change-Id: I7d160612259c77764b... — committed to jproberts/go by rsc 2 years ago
- misc/cgo/test: disable setgid tests with musl We don't have a good musl detection mechanism, so we detect Alpine (the most common user of musl) instead. For #39857. For #19938. Change-Id: I2fa39248... — committed to golang/go by prattmic 2 years ago
- misc/cgo/test: skip Test9400 on Alpine Alpine has a known issue where setgid clobbers the Go stack (#39857). misc/cgo/test skips other tests that use setgid on Alpine, but not this one. It's not clea... — committed to golang/go by aclements 2 years ago
- community/go: explicitly enable setgid tests again The underlying issue has been fixed in musl 1.2.4. See: • https://github.com/golang/go/issues/39857#issuecomment-1305876934 * https://github.com/g... — committed to alpinelinux/aports by nmeum a year ago
- universe/go: explicitly enable setgid tests again [ commit affd27c5e84301e444527a1b4a87107ed454c382 ] The underlying issue has been fixed in musl 1.2.4. See: • https://github.com/golang/go/issues/... — committed to bell-sw/alpaquita-aports by nmeum a year ago
- env/linux-x86-alpine: update version of alpine to 3.18 Updates golang/go#39857 Change-Id: Ibb2f27947d9f5f5856862dc78465215964850e95 Reviewed-on: https://go-review.googlesource.com/c/build/+/521975 A... — committed to golang/build by cagedmantis 10 months ago
- community/go: enable all setgid tests again Apart from Test9400 there are additional tests which were disabled on Alpine and should now just pass with recent musl libc. See: https://github.com/golan... — committed to alpinelinux/aports by nmeum 9 months ago
- universe/go: enable all setgid tests again [ commit 68b45368dd53d570477e8c14cef83a33a2b2d886 ] Apart from Test9400 there are additional tests which were disabled on Alpine and should now just pass w... — committed to bell-sw/alpaquita-aports by nmeum 9 months ago
Thanks for the ping. I don’t think we ever came up with a good reason we can’t use the alt stack for this, so I’m inclined to go ahead and switch to using it.
Unfortunately I am getting other breakage on Alpine 3.18, and had to revert to 3.17 due to a SIGSEGV, so an update to 3.18 might not work for everyone just yet.
(This issue here doesn’t affect me, so I’m fine, just thought I’d mention.)
Excellent news. Glad to know the changes had the desired effect!
On Alpine 3.18 (which ships musl 1.2.4) these tests seem to pass now on the architectures I have tested so far (tested by reverting https://github.com/golang/go/commit/42105eb8a5b59e715573f5299218e12be2dbb050). Is there a change that these could be enabled again?
FYI https://git.musl-libc.org/cgit/musl/commit/?id=2e5fff43dd7fc808197744c67cca7908ac19bb4f switched musl to using the alt stack for internal signals and will be present in future releases starting with 1.2.4.