x/mobile: byte slice causes application crash if after string in function parameters #9486
Comments
Running on my Android 4.3.1 device I was able to get the panic
|
I don't have the machinery to reproduce this bug today, but here's a possibility: we are not honoring the JNI semantics for GetByteArrayElements / ReleaseByteArrayElements. In particular in seq_android.c we have:
At the point that ReleaseByteArrayElements is called, the pointer b is no longer valid. ART is free to stop the world, and as part of garbage collection move the memory. That would fit with the SIGBUS @ChrisSmith is seeing. What we need to do is:
Then later inside Java_go_Seq_send, have a cleanup phase after the call
After the Send returns, the Go code will have decoded the Seq, which includes copying the bytes out of the pointer. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What version of Go are you using
go version devel +c7eb966 Wed Dec 24 07:30:28 2014 +0000 darwin/amd64
What operating system and processor architecture are you using?
osx 10.9.5 cross compiled for arm on Android 5.0.1 Nexus 5
What did you do?
Tried to call a go function from java that takes a byte[] and a string. The inverse go to java call has the same issue. If the byte[] is preceded by an int, it behaves normally.
What did you expect to see?
fmt.Printf to get called
What did you see instead?
Application crash, no error messages generated.
To reproduce, modify the libhello example by adding these functions
run gobind, then back in java add this after the initialization
The text was updated successfully, but these errors were encountered: