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

cmd/compile: nosplit stack overflow #45698

Closed
cuiweixie opened this issue Apr 22, 2021 · 4 comments
Closed

cmd/compile: nosplit stack overflow #45698

cuiweixie opened this issue Apr 22, 2021 · 4 comments
Labels
Milestone

Comments

@cuiweixie
Copy link
Contributor

@cuiweixie cuiweixie commented Apr 22, 2021

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

$ go version
go version devel go1.17-14a18b7d25 Thu Apr 22 04:07:38 2021 +0000 windows/amd64

Does this issue reproduce with the latest release?

No

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

go env Output
$ go env

$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\cuiweixie\AppData\Local\go-build
set GOENV=C:\Users\cuiweixie\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\code\go\gopath\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\code\go\gopath
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=D:\code\go\src\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=D:\code\go\src\go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=devel go1.17-381252f312 Wed Apr 21 13:27:17 2021 +0000
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=D:\code\go\src\go\src\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\CUIWEI~1\AppData\Local\Temp\go-build1006093855=/tmp/go-build -gno-record-gcc-switches

What did you do?

CGO_ENABLED=0 go build -v -gcflags "all=-N -l" .

https://play.golang.org/p/JGuMjNxG6Ov

What did you expect to see?

success

What did you see instead?

failed
`
github.com/cuiweixie/go_compiler/code/basic/demo1

github.com/cuiweixie/go_compiler/code/basic/demo1

runtime.goPanicIndexU: nosplit stack overflow
792 assumed on entry to syscall.Syscall9<1> (nosplit)
672 after syscall.Syscall9<1> (nosplit) uses 120
664 on entry to syscall.Syscall9<0> (nosplit)
616 after syscall.Syscall9<0> (nosplit) uses 48
608 on entry to runtime.deferreturn<1> (nosplit)
544 after runtime.deferreturn<1> (nosplit) uses 64
536 on entry to runtime.freedefer<1> (nosplit)
408 after runtime.freedefer<1> (nosplit) uses 128
400 on entry to runtime.gcWriteBarrierR9<1> (nosplit)
392 on entry to runtime.gcWriteBarrier<1> (nosplit)
272 after runtime.gcWriteBarrier<1> (nosplit) uses 120
264 on entry to runtime.wbBufFlush<0> (nosplit)
240 after runtime.wbBufFlush<0> (nosplit) uses 24
232 on entry to runtime.wbBufFlush<1> (nosplit)
208 after runtime.wbBufFlush<1> (nosplit) uses 24
200 on entry to runtime.cgoCheckWriteBarrier<1> (nosplit)
160 after runtime.cgoCheckWriteBarrier<1> (nosplit) uses 40
152 on entry to runtime.cgoIsGoPointer<1> (nosplit)
88 after runtime.cgoIsGoPointer<1> (nosplit) uses 64
80 on entry to runtime.inHeapOrStack<1> (nosplit)
56 after runtime.inHeapOrStack<1> (nosplit) uses 24
48 on entry to runtime.spanOf<1> (nosplit)
8 after runtime.spanOf<1> (nosplit) uses 40
0 on entry to runtime.panicIndexU<1> (nosplit)
-8 on entry to runtime.goPanicIndexU<1>

`

@aarzilli
Copy link
Contributor

@aarzilli aarzilli commented Apr 23, 2021

Likely related:

$ go version
go version devel go1.17-5963f0a332 Fri Apr 23 05:38:47 2021 +0000 linux/amd64

cross-compiling https://github.com/go-delve/delve/tree/master/_fixtures/buildtest from linux to windows:

$ GOOS=windows go build -gcflags='all=-N -l'
# github.com/go-delve/delve/_fixtures/buildtest
runtime.goPanicIndexU: nosplit stack overflow
	792	assumed on entry to syscall.Syscall9<1> (nosplit)
	672	after syscall.Syscall9<1> (nosplit) uses 120
	664	on entry to syscall.Syscall9<0> (nosplit)
	616	after syscall.Syscall9<0> (nosplit) uses 48
	608	on entry to runtime.deferreturn<1> (nosplit)
	544	after runtime.deferreturn<1> (nosplit) uses 64
	536	on entry to runtime.freedefer<1> (nosplit)
	408	after runtime.freedefer<1> (nosplit) uses 128
	400	on entry to runtime.gcWriteBarrierR9<1> (nosplit)
	392	on entry to runtime.gcWriteBarrier<1> (nosplit)
	272	after runtime.gcWriteBarrier<1> (nosplit) uses 120
	264	on entry to runtime.wbBufFlush<0> (nosplit)
	240	after runtime.wbBufFlush<0> (nosplit) uses 24
	232	on entry to runtime.wbBufFlush<1> (nosplit)
	208	after runtime.wbBufFlush<1> (nosplit) uses 24
	200	on entry to runtime.cgoCheckWriteBarrier<1> (nosplit)
	160	after runtime.cgoCheckWriteBarrier<1> (nosplit) uses 40
	152	on entry to runtime.cgoIsGoPointer<1> (nosplit)
	88	after runtime.cgoIsGoPointer<1> (nosplit) uses 64
	80	on entry to runtime.inHeapOrStack<1> (nosplit)
	56	after runtime.inHeapOrStack<1> (nosplit) uses 24
	48	on entry to runtime.spanOf<1> (nosplit)
	8	after runtime.spanOf<1> (nosplit) uses 40
	0	on entry to runtime.panicIndexU<1> (nosplit)
	-8	on entry to runtime.goPanicIndexU<1>

Loading

@cherrymui cherrymui added this to the Go1.17 milestone Apr 26, 2021
@gopherbot
Copy link

@gopherbot gopherbot commented May 3, 2021

Change https://golang.org/cl/316650 mentions this issue: runtime: call unlockOSThread directly in Windows syscall functions

Loading

@gopherbot gopherbot closed this in 4dbad79 May 6, 2021
@IncSW
Copy link

@IncSW IncSW commented Aug 5, 2021

Have nosplit stack overflow too, with //go:nosplit on go version go1.17rc2 linux/amd64
For reproduce you can try go test -c on https://github.com/IncSW/go-bencode

# github.com/IncSW/go-bencode.test
github.com/IncSW/go-bencode/internal/encoder.(*Encoder).encodeDictionary: nosplit stack overflow
        792     assumed on entry to github.com/IncSW/go-bencode/internal/encoder.(*Encoder).encodeDictionary<1> (nosplit)
        448     after github.com/IncSW/go-bencode/internal/encoder.(*Encoder).encodeDictionary<1> (nosplit) uses 344
        440     on entry to github.com/IncSW/go-bencode/internal/encoder.(*Encoder).encode<1> (nosplit)
        336     after github.com/IncSW/go-bencode/internal/encoder.(*Encoder).encode<1> (nosplit) uses 104
        328     on entry to github.com/IncSW/go-bencode/internal/encoder.(*Encoder).encodeDictionary<1> (nosplit)
        -16     after github.com/IncSW/go-bencode/internal/encoder.(*Encoder).encodeDictionary<1> (nosplit) uses 344
runtime.cgoCheckWriteBarrier: nosplit stack overflow
        792     assumed on entry to github.com/IncSW/go-bencode/internal/encoder.(*Encoder).EncodeTo<1> (nosplit)
        760     after github.com/IncSW/go-bencode/internal/encoder.(*Encoder).EncodeTo<1> (nosplit) uses 32
        752     on entry to github.com/IncSW/go-bencode/internal/encoder.(*Encoder).encode<1> (nosplit)
        648     after github.com/IncSW/go-bencode/internal/encoder.(*Encoder).encode<1> (nosplit) uses 104
        640     on entry to github.com/IncSW/go-bencode/internal/encoder.(*Encoder).encodeDictionary<1> (nosplit)
        296     after github.com/IncSW/go-bencode/internal/encoder.(*Encoder).encodeDictionary<1> (nosplit) uses 344
        288     on entry to github.com/IncSW/go-bencode/internal/encoder.(*Encoder).grow<1> (nosplit)
        232     after github.com/IncSW/go-bencode/internal/encoder.(*Encoder).grow<1> (nosplit) uses 56
        224     on entry to runtime.gcWriteBarrierDX<1> (nosplit)
        216     on entry to runtime.gcWriteBarrier<1> (nosplit)
        96      after runtime.gcWriteBarrier<1> (nosplit) uses 120
        88      on entry to runtime.wbBufFlush<0> (nosplit)
        64      after runtime.wbBufFlush<0> (nosplit) uses 24
        56      on entry to runtime.wbBufFlush<1> (nosplit)
        32      after runtime.wbBufFlush<1> (nosplit) uses 24
        24      on entry to runtime.cgoCheckWriteBarrier<1> (nosplit)
        -16     after runtime.cgoCheckWriteBarrier<1> (nosplit) uses 40
runtime.inHeapOrStack: nosplit stack overflow
        792     assumed on entry to github.com/IncSW/go-bencode/internal/encoder.(*Encoder).encode<1> (nosplit)
        688     after github.com/IncSW/go-bencode/internal/encoder.(*Encoder).encode<1> (nosplit) uses 104
        680     on entry to github.com/IncSW/go-bencode/internal/encoder.(*Encoder).encodeDictionary<1> (nosplit)
        336     after github.com/IncSW/go-bencode/internal/encoder.(*Encoder).encodeDictionary<1> (nosplit) uses 344
        328     on entry to github.com/IncSW/go-bencode/internal/encoder.(*Encoder).grow<1> (nosplit)
        272     after github.com/IncSW/go-bencode/internal/encoder.(*Encoder).grow<1> (nosplit) uses 56
        264     on entry to runtime.gcWriteBarrierDX<1> (nosplit)
        256     on entry to runtime.gcWriteBarrier<1> (nosplit)
        136     after runtime.gcWriteBarrier<1> (nosplit) uses 120
        128     on entry to runtime.wbBufFlush<0> (nosplit)
        104     after runtime.wbBufFlush<0> (nosplit) uses 24
        96      on entry to runtime.wbBufFlush<1> (nosplit)
        72      after runtime.wbBufFlush<1> (nosplit) uses 24
        64      on entry to runtime.cgoCheckWriteBarrier<1> (nosplit)
        24      after runtime.cgoCheckWriteBarrier<1> (nosplit) uses 40
        16      on entry to runtime.cgoIsGoPointer<1> (nosplit)
        0       after runtime.cgoIsGoPointer<1> (nosplit) uses 16
        -8      on entry to runtime.inHeapOrStack<1> (nosplit)
runtime.cgoCheckWriteBarrier: nosplit stack overflow
        792     assumed on entry to github.com/IncSW/go-bencode/internal/encoder.(*Encoder).encodeList<1> (nosplit)
        744     after github.com/IncSW/go-bencode/internal/encoder.(*Encoder).encodeList<1> (nosplit) uses 48
        736     on entry to github.com/IncSW/go-bencode/internal/encoder.(*Encoder).encode<1> (nosplit)
        632     after github.com/IncSW/go-bencode/internal/encoder.(*Encoder).encode<1> (nosplit) uses 104
        624     on entry to github.com/IncSW/go-bencode/internal/encoder.(*Encoder).encodeDictionary<1> (nosplit)
        280     after github.com/IncSW/go-bencode/internal/encoder.(*Encoder).encodeDictionary<1> (nosplit) uses 344
        272     on entry to github.com/IncSW/go-bencode/internal/encoder.(*Encoder).grow<1> (nosplit)
        216     after github.com/IncSW/go-bencode/internal/encoder.(*Encoder).grow<1> (nosplit) uses 56
        208     on entry to runtime.gcWriteBarrierDX<1> (nosplit)
        200     on entry to runtime.gcWriteBarrier<1> (nosplit)
        80      after runtime.gcWriteBarrier<1> (nosplit) uses 120
        72      on entry to runtime.wbBufFlush<0> (nosplit)
        48      after runtime.wbBufFlush<0> (nosplit) uses 24
        40      on entry to runtime.wbBufFlush<1> (nosplit)
        16      after runtime.wbBufFlush<1> (nosplit) uses 24
        8       on entry to runtime.cgoCheckWriteBarrier<1> (nosplit)
        -32     after runtime.cgoCheckWriteBarrier<1> (nosplit) uses 40

Loading

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Aug 5, 2021

@IncSW This issue is fixed and closed. You are running into a different problem that coincidentally has similar symptoms. It should be in a new issue, not here.

That said, the problem is that https://github.com/IncSW/go-bencode/blob/master/internal/encoder/encoder.go uses go:nosplit comments. The go:nosplit directive is for low-level runtime code. Using it outside of the standard library is not part of the Go 1 compatibility guarantee. It looks like with the Go 1.17 release this particular use no longer works. This has to be addressed in go-bencode, not in the Go standard library.

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants