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

runtime/cgo: the object returned CFBundleCopyResourceURL should be released #19722

Closed
echo2gold opened this issue Mar 27, 2017 · 2 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@echo2gold
Copy link

Please answer these questions before submitting your issue. Thanks!

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

go version go1.8 darwin/amd64

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/mymac/workspace/gomobile"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/z1/4wwl0fpj7x7_8k42nnxxzs7r0000gn/T/go-build994212619=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="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?

$ gomobile bind -v -target=ios golang.org/x/mobile/example/bind/hello

The hello example for binding with go has leak the memory type NSURL and CFString in init_working_dir().

https://github.com/golang/go/search?utf8=%E2%9C%93&q=CFBundleCopyResourceURL

The object returned CFBundleCopyResourceURL should be released because it's ownership follows the The Create Rule.

https://developer.apple.com/reference/corefoundation/1537117-cfbundlecopyresourceurl?language=objc

@bradfitz
Copy link
Contributor

@eliasnaur, @ianlancetaylor?

@bradfitz bradfitz added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 27, 2017
@bradfitz bradfitz added this to the Go1.9Maybe milestone Mar 27, 2017
@ianlancetaylor ianlancetaylor changed the title cmd/cgo: the object returned CFBundleCopyResourceURL should be released runtime/cgo: the object returned CFBundleCopyResourceURL should be released Mar 27, 2017
@eliasnaur eliasnaur self-assigned this Mar 27, 2017
@gopherbot
Copy link

CL https://golang.org/cl/38639 mentions this issue.

lparth pushed a commit to lparth/go that referenced this issue Apr 13, 2017
The result from CFBundleCopyResourceURL is owned by the caller. This
CL adds the necessary CFRelease to release it after use.

Fixes golang#19722

Change-Id: I7afe22ef241d21922a7f5cef6498017e6269a5c3
Reviewed-on: https://go-review.googlesource.com/38639
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
@golang golang locked and limited conversation to collaborators Mar 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants