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

runtime: segmentation violation while adjusting stack pointer #61728

Open
WAY29 opened this issue Aug 3, 2023 · 5 comments
Open

runtime: segmentation violation while adjusting stack pointer #61728

WAY29 opened this issue Aug 3, 2023 · 5 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@WAY29
Copy link

WAY29 commented Aug 3, 2023

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

$ go version
go version go1.20.6 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="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/coding/golang/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/coding/golang"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/root/.go/go1.20.6"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/root/.go/go1.20.6/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.6"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build649550129=/tmp/go-build -gno-record-gcc-switches"

What did you do?

When I attempt to debug my project in VS Code by connecting to WSL2 using remote-wsl, I encounter a fatal error. The error occurs with a high probability, but it is not guaranteed to happen every time.

What did you expect to see?

Debug normally

What did you see instead?

"unexpected signal during runtime execution"
Stack:
	0  0x0000000000448720 in runtime.throw
	    at /root/.go/go1.20.6/src/runtime/panic.go:1040
	1  0x0000000000460865 in runtime.sigpanic
	    at /root/.go/go1.20.6/src/runtime/signal_unix.go:825
	2  0x000000000042c010 in runtime.scanstack
	    at /root/.go/go1.20.6/src/runtime/mgcmark.go:810
	3  0x000000000042acc5 in runtime.markroot.func1
	    at /root/.go/go1.20.6/src/runtime/mgcmark.go:239
	4  0x000000000042a979 in runtime.markroot
	    at /root/.go/go1.20.6/src/runtime/mgcmark.go:213
	5  0x000000000042cab8 in runtime.gcDrain
	    at /root/.go/go1.20.6/src/runtime/mgcmark.go:1069
	6  0x0000000000428aed in runtime.gcBgMarkWorker.func2
	    at /root/.go/go1.20.6/src/runtime/mgc.go:1367
	7  0x000000000047e409 in runtime.systemstack
	    at /root/.go/go1.20.6/src/runtime/asm_amd64.s:496
	8  0x00007f6b2bffe9ff in ???
	    at ?:-1
	    error: input/output error
	(truncated)
@dr2chase dr2chase added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 3, 2023
@dr2chase
Copy link
Contributor

dr2chase commented Aug 3, 2023

@golang/tools-team

Pinging @qmuntal in case this rings any Windows bells.

@qmuntal
Copy link
Contributor

qmuntal commented Aug 4, 2023

I'll need more information to reproduce this issue. Are you using Delve? If so, which version? Can you share a reproducer and some instructions to get to the fatal error?

Thanks.

@WAY29
Copy link
Author

WAY29 commented Aug 4, 2023

I'll need more information to reproduce this issue. Are you using Delve? If so, which version? Can you share a reproducer and some instructions to get to the fatal error?

Thanks.

❯ dlv version
Delve Debugger
Version: 1.21.0
Build: $Id: fec0d226b2c2cce1567d5f59169660cf61dc1efe $

I just debug program in vscode use debug test button, and fatal error occurs randomly, the command vscode run is:dlv dap --listen=127.0.0.1:41301 --log-dest=3 from /src/yaklang/common/yak/yaktest/mustpass

@qmuntal
Copy link
Contributor

qmuntal commented Aug 4, 2023

Thanks @WAY29.

I manage to reproduce the unexpected signal during runtime execution, although with a different call stack (see below).

It looks like an issue in the Go runtime, I don't see how it can be related to running on WSL, and definitely not a Delve remote debugging issue, as running the test by hand also throws.

More info:

  • It also fails with go1.20rc4.
  • It fails when running go test -gcflags="all=-N -l" -v ./common/yak/yaktest/mustpass, rooted at https://github.com/yaklang/yaklang.
  • It doesn't fail if -gcflags is not set.
[signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0x462be0]

runtime stack:
runtime.throw({0x31cf13d?, 0x416f99?})
	/home/qmuntaldiaz/sdk/go1.20.7/src/runtime/panic.go:1047 +0x5d fp=0x7f226cad9850 sp=0x7f226cad9820 pc=0x44869d
runtime.sigpanic()
	/home/qmuntaldiaz/sdk/go1.20.7/src/runtime/signal_unix.go:825 +0x285 fp=0x7f226cad9880 sp=0x7f226cad9850 pc=0x460785
runtime.adjustpointer(0x463245?, 0x12f?)
	/home/qmuntaldiaz/sdk/go1.20.7/src/runtime/stack.go:573 fp=0x7f226cad9888 sp=0x7f226cad9880 pc=0x462be0
runtime.adjustdefers(0xc0000061a0, 0xc08?)
	/home/qmuntaldiaz/sdk/go1.20.7/src/runtime/stack.go:765 +0x58 fp=0x7f226cad98b8 sp=0x7f226cad9888 pc=0x4632d8
runtime.copystack(0xc0000061a0, 0x10000)
	/home/qmuntaldiaz/sdk/go1.20.7/src/runtime/stack.go:921 +0x209 fp=0x7f226cad9a70 sp=0x7f226cad98b8 pc=0x463829
runtime.shrinkstack(0xc0000061a0)
	/home/qmuntaldiaz/sdk/go1.20.7/src/runtime/stack.go:1216 +0x134 fp=0x7f226cad9a98 sp=0x7f226cad9a70 pc=0x464814
runtime.scanstack(0xc0000061a0, 0xc00006d238)
	/home/qmuntaldiaz/sdk/go1.20.7/src/runtime/mgcmark.go:775 +0x10b fp=0x7f226cad9cb8 sp=0x7f226cad9a98 pc=0x42bd4b
runtime.markroot.func1()
	/home/qmuntaldiaz/sdk/go1.20.7/src/runtime/mgcmark.go:239 +0xc5 fp=0x7f226cad9d08 sp=0x7f226cad9cb8 pc=0x42abe5
runtime.markroot(0xc00006d238, 0x3a, 0x1)
	/home/qmuntaldiaz/sdk/go1.20.7/src/runtime/mgcmark.go:213 +0x199 fp=0x7f226cad9da8 sp=0x7f226cad9d08 pc=0x42a899
runtime.gcDrain(0xc00006d238, 0x3)
	/home/qmuntaldiaz/sdk/go1.20.7/src/runtime/mgcmark.go:1069 +0x378 fp=0x7f226cad9e00 sp=0x7f226cad9da8 pc=0x42c9d8
runtime.gcBgMarkWorker.func2()
	/home/qmuntaldiaz/sdk/go1.20.7/src/runtime/mgc.go:1348 +0xa5 fp=0x7f226cad9e50 sp=0x7f226cad9e00 pc=0x428a45
runtime.systemstack()
	/home/qmuntaldiaz/sdk/go1.20.7/src/runtime/asm_amd64.s:496 +0x49 fp=0x7f226cad9e58 sp=0x7f226cad9e50 pc=0x47e1e9

@golang/runtime

@qmuntal qmuntal added the compiler/runtime Issues related to the Go compiler and/or runtime. label Aug 4, 2023
@qmuntal qmuntal changed the title debug get fatal error in WSL2 vscode runtime: segmentation violation while adjusting stack pointer Aug 4, 2023
@mknyszek mknyszek added this to the Backlog milestone Aug 9, 2023
@dr2chase
Copy link
Contributor

dr2chase commented Aug 11, 2023

There's a lot of what I'd call gratuitous unsafe code in there.

If it were me, I would take all the little unsafe-using functions, write less-efficient safe versions of the same, and put them under a build tag to allow testing with all the unsafe code avoided. Otherwise, my default assumption is you accidentally broke a runtime rule (they can be subtle) in unsafe code.

The sort of short functions I'd expect to see from this would all inline trivially, and thus cost nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
Development

No branches or pull requests

4 participants