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

x/mobile/asset: calling asset.Open from init causes crash #12077

Closed
hyangah opened this issue Aug 8, 2015 · 1 comment
Closed

x/mobile/asset: calling asset.Open from init causes crash #12077

hyangah opened this issue Aug 8, 2015 · 1 comment

Comments

@hyangah
Copy link
Contributor

hyangah commented Aug 8, 2015

The asset package relies on golang.org/x/mobile/internal/mobileinit package's Context.

The mobileinit.Context is valid only after JavaVM and android.context.Context are set through the mobileinit.SetContext.

mobileinit.SetContext is called when the libgojni is first loaded.
This is a Java-JNI-cgo-Go call path; the Go runtime initialization and all the init functions must run to execute mobileinit.SetContext.

Calling asset.Open from init() means querying mobileinit.Context before mobileinit.SetContext completes. As a result, invalid java VM and android Context are used, causing a crash.

Either document it properly so access to assets must not happen in init, or fix it.

@crawshaw

@hyangah hyangah self-assigned this Aug 8, 2015
@hyangah hyangah added this to the Unplanned milestone Aug 8, 2015
@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Aug 9, 2016
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
Currently there is no easy way to fix golang/go#12077
so we document it.

Fixes golang/go#12077

Change-Id: I6b37ae375673c055152dad5b93e180d9831aef76
Reviewed-on: https://go-review.googlesource.com/13430
Reviewed-by: David Crawshaw <crawshaw@golang.org>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 11, 2021
Currently there is no easy way to fix golang/go#12077
so we document it.

Fixes golang/go#12077

Change-Id: I6b37ae375673c055152dad5b93e180d9831aef76
Reviewed-on: https://go-review.googlesource.com/13430
Reviewed-by: David Crawshaw <crawshaw@golang.org>
@rsc rsc unassigned hyangah Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants