Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/sys: some trampolines on darwin/amd64 still causing "unexpected return pc for runtime.sigpanic" #45939

Closed
mark-rushakoff opened this issue May 4, 2021 · 1 comment

Comments

@mark-rushakoff
Copy link
Contributor

What version of Go are you using (go version)?

$ go version
go version devel go1.17-e3769299cd Tue May 4 00:56:00 2021 +0000 darwin/amd64

Does this issue reproduce with the latest release?

n/a

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/mr/Library/Caches/go-build"
GOENV="/Users/mr/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/mr/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/mr/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/mr/gotip/src/github.com/golang/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/mr/gotip/src/github.com/golang/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="devel go1.17-e3769299cd Tue May 4 00:56:00 2021 +0000"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/tmp/goissue45702/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/ct/bl4_z3g51ks8239_r2k07v_40000gn/T/go-build4031339727=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I regularly build and test our closed source projects with go tip. They had been running and testing fine until recently, when I started seeing some unexpected return pc panics.

I commented at #45702 (comment), but in hindsight that may have been a slightly different, although related, issue.

@cherrymui's fix in 731a015 stopped my minimized reproducer from crashing, but then when I rebuilt the primary project with go tip including that fix, I saw two new trampoline calls in the stack from different tests.

It looks like the existing use of funcPC at e.g. https://github.com/golang/sys/blob/0981d6026fa6241c75c6949829b5bd7a2574ad55/unix/zsyscall_darwin_amd64.go#L690 ought to also switch to internal/abi.FuncPCABI0 (maybe?), but I am not sure whether x/sys is allowed to call into internal/abi. Nor am I sure whether that is the appropriate fix.

What did you expect to see?

Tests passing.

What did you see instead?

Two new panics related to golang.org/x/sys/unix.libc_munmap_trampoline+0x0000000000000005 and golang.org/x/sys/unix.libc_ioctl_trampoline+0x0000000000000005. I assume this needs to be fixed beyond just those two cases, but those are the first two I've hit in our codebase.

One runtime stack for ioctl
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb01dfacedebac1e pc=0x7fff708253a6]

runtime stack:
runtime: unexpected return pc for runtime.sigpanic called from 0x7fff708253a6
stack: frame={sp:0x7ffeefbff3a8, fp:0x7ffeefbff3f8} stack=[0x7ffeefb80448,0x7ffeefbff4b0)
0x00007ffeefbff2a8:  0x01007ffeefbff2c8  0x0000000000000004
0x00007ffeefbff2b8:  0x000000000000001f  0x00007fff708253a6
0x00007ffeefbff2c8:  0x0b01dfacedebac1e  0x0000000000000001
0x00007ffeefbff2d8:  0x00007ffeefbff378  0x0000000004037ff1 <runtime.throw+0x0000000000000071>
0x00007ffeefbff2e8:  0x000000000505278e  0x00007ffeefbff330
0x00007ffeefbff2f8:  0x00000000040382a8 <runtime.fatalthrow.func1+0x0000000000000048>  0x000000000592eba0
0x00007ffeefbff308:  0x0000000000000001  0x0000000000000001
0x00007ffeefbff318:  0x00007ffeefbff378  0x0000000004037ff1 <runtime.throw+0x0000000000000071>
0x00007ffeefbff328:  0x000000000592eba0  0x00007ffeefbff368
0x00007ffeefbff338:  0x0000000004038230 <runtime.fatalthrow+0x0000000000000050>  0x00007ffeefbff348
0x00007ffeefbff348:  0x0000000004038260 <runtime.fatalthrow.func1+0x0000000000000000>  0x000000000592eba0
0x00007ffeefbff358:  0x0000000004037ff1 <runtime.throw+0x0000000000000071>  0x00007ffeefbff378
0x00007ffeefbff368:  0x00007ffeefbff398  0x0000000004037ff1 <runtime.throw+0x0000000000000071>
0x00007ffeefbff378:  0x00007ffeefbff380  0x0000000004038020 <runtime.throw.func1+0x0000000000000000>
0x00007ffeefbff388:  0x000000000505fae1  0x000000000000002a
0x00007ffeefbff398:  0x00007ffeefbff3e8  0x000000000404fbb6 <runtime.sigpanic+0x0000000000000396>
0x00007ffeefbff3a8: <0x000000000505fae1  0x00000000055d86c8
0x00007ffeefbff3b8:  0x00000000058c0680  0x000000000415c228 <testing.(*T).Run·dwrap·21+0x0000000000000048>
0x00007ffeefbff3c8:  0x0000000008c010e0  0x0000000000000008
0x00007ffeefbff3d8:  0x000000000bc02258  0x0000000000000000
0x00007ffeefbff3e8:  0x00007ffeefbff430 !0x00007fff708253a6
0x00007ffeefbff3f8: >0x00007ffeefbff430  0x0000000005877000
0x00007ffeefbff408:  0x000000000000084d  0x0000000004950f65 <golang.org/x/sys/unix.libc_ioctl_trampoline+0x0000000000000005>
0x00007ffeefbff418:  0x000000000406fb3f <runtime.syscall+0x000000000000001f>  0x000000c0000766a0
0x00007ffeefbff428:  0x000000000406f4ac <runtime.nanotime_trampoline+0x000000000000000c>  0x000000c000076670
0x00007ffeefbff438:  0x000000000406d2b0 <runtime.asmcgocall+0x0000000000000070>  0x0000000008880008
0x00007ffeefbff448:  0x0000000004bc27e6  0x0000000004bc2760
0x00007ffeefbff458:  0x0000000000021928  0x0000000000021928
0x00007ffeefbff468:  0x00000000000009b8  0x000000c0001fda00
0x00007ffeefbff478:  0x000000000406ed9a <racecall+0x000000000000001a>  0x0000000000000004
0x00007ffeefbff488:  0x00000000051b6f50  0x000000000592eba0
0x00007ffeefbff498:  0x00007ffeefbff4e0  0x000000000406b2c5 <runtime.mstart+0x0000000000000005>
0x00007ffeefbff4a8:  0x000000000406b27d <runtime.rt0_go+0x000000000000013d>
runtime.throw({0x505fae1, 0x55d86c8})
One runtime stack for munmap
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb01dfacedebac1e pc=0x7fff708253a6]

runtime stack:
runtime: unexpected return pc for runtime.sigpanic called from 0x7fff708253a6
stack: frame={sp:0x70000cf92db8, fp:0x70000cf92e08} stack=[0x70000cf13298,0x70000cf92e98)
0x000070000cf92cb8:  0x010070000cf92cd8  0x0000000000000004
0x000070000cf92cc8:  0x000000000000001f  0x00007fff708253a6
0x000070000cf92cd8:  0x0b01dfacedebac1e  0x0000000000000001
0x000070000cf92ce8:  0x000070000cf92d88  0x0000000004038431 <runtime.throw+0x0000000000000071>
0x000070000cf92cf8:  0x000000000556b839  0x000070000cf92d40
0x000070000cf92d08:  0x00000000040386e8 <runtime.fatalthrow.func1+0x0000000000000048>  0x000000c0006824e0
0x000070000cf92d18:  0x0000000000000001  0x0000000000000001
0x000070000cf92d28:  0x000070000cf92d88  0x0000000004038431 <runtime.throw+0x0000000000000071>
0x000070000cf92d38:  0x000000c0006824e0  0x000070000cf92d78
0x000070000cf92d48:  0x0000000004038670 <runtime.fatalthrow+0x0000000000000050>  0x000070000cf92d58
0x000070000cf92d58:  0x00000000040386a0 <runtime.fatalthrow.func1+0x0000000000000000>  0x000000c0006824e0
0x000070000cf92d68:  0x0000000004038431 <runtime.throw+0x0000000000000071>  0x000070000cf92d88
0x000070000cf92d78:  0x000070000cf92da8  0x0000000004038431 <runtime.throw+0x0000000000000071>
0x000070000cf92d88:  0x000070000cf92d90  0x0000000004038460 <runtime.throw.func1+0x0000000000000000>
0x000070000cf92d98:  0x000000000557c0fd  0x000000000000002a
0x000070000cf92da8:  0x000070000cf92df8  0x0000000004050196 <runtime.sigpanic+0x0000000000000396>
0x000070000cf92db8: <0x000000000557c0fd  0x000000000c679bd8
0x000070000cf92dc8:  0x0000000005031fe9  0x0000000000000000
0x000070000cf92dd8:  0x000000000c46f860  0x000000000c46f860
0x000070000cf92de8:  0x000003ff00000002  0x000003ffffffffff
0x000070000cf92df8:  0x000070000cf92e40 !0x00007fff708253a6
0x000070000cf92e08: >0x000070000cf92e40  0x00000000064ab000
0x000070000cf92e18:  0x0000000000000a4b  0x0000000004c442a5 <golang.org/x/sys/unix.libc_munmap_trampoline+0x0000000000000005>
0x000070000cf92e28:  0x000000000407009f <runtime.syscall+0x000000000000001f>  0x000000c0000fb498
0x000070000cf92e38:  0x000000c00032a000  0x000000c0000fb468
0x000070000cf92e48:  0x000000000406d7d0 <runtime.asmcgocall+0x0000000000000070>  0x0000000005027e20
0x000070000cf92e58:  0x000000000c6d9000  0x000000000502ca80
0x000070000cf92e68:  0x00000000055ed140  0x00000000055ed140
0x000070000cf92e78:  0x0000000000000bc0  0x000000c0001fd860
0x000070000cf92e88:  0x000000000406f2da <racecall+0x000000000000001a>  0x000070000cf92ef0
runtime.throw({0x557c0fd, 0xc679bd8})
	/Users/mr/gotip/src/github.com/golang/go/src/runtime/panic.go:1198 +0x71
runtime: unexpected return pc for runtime.sigpanic called from 0x7fff708253a6
stack: frame={sp:0x70000cf92db8, fp:0x70000cf92e08} stack=[0x70000cf13298,0x70000cf92e98)
0x000070000cf92cb8:  0x010070000cf92cd8  0x0000000000000004
0x000070000cf92cc8:  0x000000000000001f  0x00007fff708253a6
0x000070000cf92cd8:  0x0b01dfacedebac1e  0x0000000000000001
0x000070000cf92ce8:  0x000070000cf92d88  0x0000000004038431 <runtime.throw+0x0000000000000071>
0x000070000cf92cf8:  0x000000000556b839  0x000070000cf92d40
0x000070000cf92d08:  0x00000000040386e8 <runtime.fatalthrow.func1+0x0000000000000048>  0x000000c0006824e0
0x000070000cf92d18:  0x0000000000000001  0x0000000000000001
0x000070000cf92d28:  0x000070000cf92d88  0x0000000004038431 <runtime.throw+0x0000000000000071>
0x000070000cf92d38:  0x000000c0006824e0  0x000070000cf92d78
0x000070000cf92d48:  0x0000000004038670 <runtime.fatalthrow+0x0000000000000050>  0x000070000cf92d58
0x000070000cf92d58:  0x00000000040386a0 <runtime.fatalthrow.func1+0x0000000000000000>  0x000000c0006824e0
0x000070000cf92d68:  0x0000000004038431 <runtime.throw+0x0000000000000071>  0x000070000cf92d88
0x000070000cf92d78:  0x000070000cf92da8  0x0000000004038431 <runtime.throw+0x0000000000000071>
0x000070000cf92d88:  0x000070000cf92d90  0x0000000004038460 <runtime.throw.func1+0x0000000000000000>
0x000070000cf92d98:  0x000000000557c0fd  0x000000000000002a
0x000070000cf92da8:  0x000070000cf92df8  0x0000000004050196 <runtime.sigpanic+0x0000000000000396>
0x000070000cf92db8: <0x000000000557c0fd  0x000000000c679bd8
0x000070000cf92dc8:  0x0000000005031fe9  0x0000000000000000
0x000070000cf92dd8:  0x000000000c46f860  0x000000000c46f860
0x000070000cf92de8:  0x000003ff00000002  0x000003ffffffffff
0x000070000cf92df8:  0x000070000cf92e40 !0x00007fff708253a6
0x000070000cf92e08: >0x000070000cf92e40  0x00000000064ab000
0x000070000cf92e18:  0x0000000000000a4b  0x0000000004c442a5 <golang.org/x/sys/unix.libc_munmap_trampoline+0x0000000000000005>
0x000070000cf92e28:  0x000000000407009f <runtime.syscall+0x000000000000001f>  0x000000c0000fb498
0x000070000cf92e38:  0x000000c00032a000  0x000000c0000fb468
0x000070000cf92e48:  0x000000000406d7d0 <runtime.asmcgocall+0x0000000000000070>  0x0000000005027e20
0x000070000cf92e58:  0x000000000c6d9000  0x000000000502ca80
0x000070000cf92e68:  0x00000000055ed140  0x00000000055ed140
0x000070000cf92e78:  0x0000000000000bc0  0x000000c0001fd860
0x000070000cf92e88:  0x000000000406f2da <racecall+0x000000000000001a>  0x000070000cf92ef0
runtime.sigpanic()
	/Users/mr/gotip/src/github.com/golang/go/src/runtime/signal_unix.go:719 +0x396
@gopherbot gopherbot added this to the Unreleased milestone May 4, 2021
@cherrymui
Copy link
Member

Thanks for reporting. I think we can continue on the previous issue, which is still open. Closing this as a dup. Thanks.

@golang golang locked and limited conversation to collaborators May 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants