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

Most upvoted comments

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.)

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 42105eb). Is there a change that these could be enabled again?

Excellent news. Glad to know the changes had the desired effect!

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.

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.