Skip to content

x/mobile: byte slice causes application crash if after string in function parameters #9486

Closed
@ChrisSmith

Description

@ChrisSmith

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

// This ordering of the parameters works
func OkFunc(someBytes []byte, str string) {
    fmt.Printf("Got a string %s and some bytes %v!\n", str, someBytes)
}
// This ordering causes a crash
func CrashFunc(str string, someBytes []byte) {
    fmt.Printf("Got a string %s and some bytes %v!\n", str, someBytes)
}

run gobind, then back in java add this after the initialization

// create a byte array, size/content isn't important 
byte[] bytes = new byte[1024];
for(int i=0;i < bytes.length; i++){
    bytes[i] = 8; 
}

// This one works
Hi.OkFunc(bytes, "stuff");
// This one crashes
Hi.CrashFunc("stuff", bytes);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions