cmd/compile: KeepAlive doesn't actually keep stack object alive #30476
Labels
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
release-blocker
Milestone
What version of Go are you using (
go version
)?tip (62f5e81)
Does this issue reproduce with the latest release?
Yes with Go 1.12. No with Go 1.11.
What operating system and processor architecture are you using (
go env
)?darwin/amd64
What did you do?
(no playground link as the playground seems down...)
What did you expect to see?
KeepAlive(p)
keeps p alive, which in turn keeps x alive, so the finalizer does not run, and the program deadlocks.This is the behavior with Go 1.11.
This is also the behavior if we use a dummy use call to keep p alive (i.e. the equivalent of the non-intrinsic runtime.KeepAlive).
What did you see instead?
Finalizer runs.
This is because the address of the stack object is rematerializeable, and the compiler just ignores KeepAlive on rematerializeable values. I'll send a CL.
The text was updated successfully, but these errors were encountered: