-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/cgo: add JNI's jmethodID/jfieldID to uintptr for Android NDK #40955
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
Conversation
Adding the test in a few minutes |
This PR (HEAD: 752d04f) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/249744 to see it. Tip: You can toggle comments from me using the |
Message from Gobot Gobot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/249744. |
In Android's NDK, jmethodID and jfieldID are defined as: struct _jfieldID; /* opaque structure */ typedef struct _jfieldID* jfieldID; /* field IDs */ struct _jmethodID; /* opaque structure */ typedef struct _jmethodID* jmethodID; /* method IDs */ Since Go seems them as pointers, a crash can occur at runtime if the GC tries to dereference those pointers. This is very reproducible in Android 11 for some reason. Add those two types to the badJNI types and rework the check logic a bit. Fixes #40954 Signed-off-by: Steeve Morin <[email protected]>
This PR (HEAD: fd17877) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/249744 to see it. Tip: You can toggle comments from me using the |
Message from Emmanuel Odeke: Patch Set 2: Run-TryBot+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/249744. |
Message from Gobot Gobot: Patch Set 2: TryBots beginning. Status page: https://farmer.golang.org/try?commit=d25c3654 Please don’t reply on this GitHub thread. Visit golang.org/cl/249744. |
Message from Gobot Gobot: Patch Set 2: TryBot-Result+1 TryBots are happy. Please don’t reply on this GitHub thread. Visit golang.org/cl/249744. |
Message from Steeve Morin: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/249744. |
Message from Keith Randall: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/249744. |
Message from Emmanuel Odeke: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/249744. |
Message from Go Bot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/249744. |
Message from Go Bot: Patch Set 2: TryBots beginning. Status page: https://farmer.golang.org/try?commit=d25c3654 Please don’t reply on this GitHub thread. Visit golang.org/cl/249744. |
Message from Go Bot: Patch Set 2: TryBot-Result+1 TryBots are happy. Please don’t reply on this GitHub thread. Visit golang.org/cl/249744. |
Hey all. I think we can merge this. I'm just coming back to it (we were running on a fork). |
@steeve Note that few people see comments on GitHub pull requests. The best place to comment is in Gerritt, in this case at https://golang.org/cl/249744. That said, the expectation here was that this was fixed by https://golang.org/cl/250940, and that this particular pull request is not needed. The associated issue #40954 is closed as fixed. If that issue is not fixed, please reply on that issue, or open a new one. Thanks. |
This PR is being closed because golang.org/cl/249744 has been abandoned. We think that the problem this patch addresses was fixed by https://golang.org/cl/250940. Please comment here or at https://golang.org/issue/40954 if you don't agree. Thanks. |
Indeed! Sorry for the noise! |
I'm sorry to report that I got a crash on vanilla Go 1.17.2 when trying to manipulate
They are indeed not in the heap, but it seems since they are opaque types disguised as pointer, some check still try to figure out if they are valid (they are not). With this PR applied, the crash is fixed, however. |
In Android's NDK, jmethodID and jfieldID are defined as:
Since Go seems them as pointers, a crash can occur at runtime if the GC
tries to dereference those pointers. This is very reproducible in
Android 11 for some reason.
Add those two types to the badJNI types and rework the check logic a
bit.
Fixes #40954