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: defer runtime.KeepAlive bug #21402
Comments
Note that (from the spec)
so *edited |
@ALTree Isn't that the idea? You want to call runtime.KeepAlive at the last point where you want the object to be live. |
@cespare I see your point. But I wonder if a EDIT: nevermind, I just noticed it happens without |
I think I see what is going on here. Replace
The finalizer runs early with This all looks correct for these |
Change https://golang.org/cl/55150 mentions this issue: |
I don't think this should be a release blocker. |
I'm marking it a release-blocker for 1.10. |
What version of Go are you using (
go version
)?go version go1.8.3 darwin/amd64
go1.8 (go playground)
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/bramp/go"
GORACE=""
GOROOT="/Users/bramp/homebrew/Cellar/go/1.8.3/libexec"
GOTOOLDIR="/Users/bramp/homebrew/Cellar/go/1.8.3/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="/usr/bin/clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/vw/07nbdcm16wn7mnzd252c44s0008gng/T/go-build574481541=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="/usr/bin/clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
What did you do?
https://play.golang.org/p/165ZsI_FUf
What did you expect to see?
I expected the
defer runtime.KeepAlive
to keepo
reachable until the end of the main function, and to be finalised afterwards.What did you see instead?
However,
o
was finalised before the main function ended, and before the defer statement was called.The text was updated successfully, but these errors were encountered: