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: Possible stack corruption when passing pointer to a "named return variable" to deferred function #13587
Comments
Preliminary guess: problem with escape analysis. Sending to @dr2chase to check. |
It looks like maybe it's a missing write barrier due to
However, the difference is that the implicit CC @aclements |
CL https://golang.org/cl/17762 mentions this issue. |
I think this is worthy of 1.5.3, if there is one. |
CL https://golang.org/cl/17759 mentions this issue. |
After fixing #13587, I noticed that the "OAS2FUNC in disguise" block looked like it probably needed write barriers too. However, testing revealed the multi-value "return f()" case was already being handled correctly. It turns out this block is dead code due to "return f()" already being transformed into "t1, t2, ..., tN := f(); return t1, t2, ..., tN" by orderstmt when f is a multi-valued function. Updates #13587. Change-Id: Icde46dccc55beda2ea5fd5fcafc9aae26cec1552 Reviewed-on: https://go-review.googlesource.com/17759 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Repro code: https://github.com/prashantv/defer-repro/blob/master/main.go
(The current version is the simplest repro, but takes longer to run. Older versions crash faster but have more code)
Using named returns, and passing a pointer to the return value to another function seems to cause some sort of stack corruption sometimes. Running the code tends to crash either either:
or with
Modifying
methodWithError
to not return directly, but set to the return variable, stops the panic.Version information:
$ go version go version go1.5.1 darwin/amd64 $ uname -prsv Darwin 15.2.0 Darwin Kernel Version 15.2.0: Fri Nov 13 19:56:56 PST 2015; root:xnu-3248.20.55~2/RELEASE_X86_64 i386
(Does not seem OSX specific however, we also saw this issue on Linux x64)
The text was updated successfully, but these errors were encountered: