-
Notifications
You must be signed in to change notification settings - Fork 18k
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: panic: dvarint: bad offset for funcdata #52697
Comments
@cherrymui @dr2chase This looks like one of ours, someone has been fuzzing the compiler. I don't know that it actually requires generics. |
This is failure to correctly complain about a ginormous stack frame, not generics -- generics just allow us to say "ginormous stack frame" in fewer words. This can be seen by replacing the array dimensions "10" and "6" with constants, and varying them between larger and smaller sizes and watch the error come and go. That said, we should complain more gracefully. |
As a simpler reproduction case, this short program fails to compile with |
The problem comes from emitting open defer info. It's even worse because it could prevent valid code to be compiled. For example, this program should compile ok, but panic during runtime due to stack overflow:
but currently panic during compile time with open defer. |
Change https://go.dev/cl/535077 mentions this issue: |
The funcdata is encoded as varint, with the upper limit set to 1e9. However, the stack offsets could be up to 1<<30. Thus emitOpenDeferInfo will trigger an ICE for function with large frame size. By using binary.PutUvarint, the frame offset could be encoded correctly for value larger than 1<<35, allow the compiler to report the error. Further, the runtime also do validation when reading in the funcdata value, so a bad offset won't likely cause mis-behavior. Fixes golang#52697 Change-Id: I084c243c5d24c5d31cc22d5b439f0889e42b107c Reviewed-on: https://go-review.googlesource.com/c/go/+/535077 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://go.dev/play/p/SJUm7jbaIjh
What did you expect to see?
The compiler don't panic and compile successfully or report "stack frame too large (>1GB)"
What did you see instead?
panic: dvarint: bad offset for funcdata - 1087887713
goroutine 20 [running]:
cmd/compile/internal/ssagen.dvarint(0xc00031c200?, 0xc0000e8a08?, 0x11?)
/usr/local/go/src/cmd/compile/internal/ssagen/ssa.go:287 +0x205
cmd/compile/internal/ssagen.(*state).emitOpenDeferInfo(0xc0002ead00)
/usr/local/go/src/cmd/compile/internal/ssagen/ssa.go:326 +0xfe
cmd/compile/internal/ssagen.buildssa(0xc0003bef20, 0x1)
/usr/local/go/src/cmd/compile/internal/ssagen/ssa.go:605 +0x1ffd
cmd/compile/internal/ssagen.Compile(0xc0003bef20, 0xc00003cf90?)
/usr/local/go/src/cmd/compile/internal/ssagen/pgen.go:183 +0x4c
cmd/compile/internal/gc.compileFunctions.func4.1(0x0?)
/usr/local/go/src/cmd/compile/internal/gc/compile.go:153 +0x3a
cmd/compile/internal/gc.compileFunctions.func3.1()
/usr/local/go/src/cmd/compile/internal/gc/compile.go:140 +0x4d
created by cmd/compile/internal/gc.compileFunctions.func3
/usr/local/go/src/cmd/compile/internal/gc/compile.go:138 +0x78
Go build failed.
The text was updated successfully, but these errors were encountered: