-
Notifications
You must be signed in to change notification settings - Fork 1.7k
MacOS native image calling JNI code: passed in argument to JNI call always passed as 0 #2152
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
Comments
You should determine whether the native method gets the correct value for |
@dmlloyd It works correctly unaltered running on the JVM on MacOS. |
@dmlloyd you got it! Added debug in JNI code to print out count:
Will rename ticket. |
I guess this parameter should be appearing in R8. But since (I think?) Darwin and Linux are using the same calling convention, if it worked on Linux, it should work on Darwin too...? |
What happens if you put the |
Putting the count parameter before the buf works: https://circleci.com/workflow-run/3a8309b3-6f59-4017-a4de-c979d595fc90 |
updated https://github.com/epiccastle/graal-jni-unix-socket-test with new information |
Thank you for your report @retrogradeorbit ! I have looked into this and I believe the problem is not with the calling convention. Instead, in |
@peter-hofer Ah that is interesting. I was playing around with other ways of passing the parameters and experiencing all kinds of strangeness, including on linux. And in every case I was using GetByteArrayElements. I will test when your patch lands in the dev builds. |
Great! I thought it might be something about parameter type handling. I'm glad that the solution was found! |
Fixed in 4653525, thanks @retrogradeorbit , @dmlloyd and @olpaw ! |
Describe GraalVM and your environment :
Run the following to capture compiler version
cl.exe
cc -v
gcc --version
Run the following to capture linker version
cl.exe
cc -Wl,-v
gcc -Wl,--version
java -Xinternalversion
:Have you verified this issue still happens when using the latest snapshot?
Yes. Happens on all MacOS native-images up to and including 20.1.0-dev
Describe the issue
JNI code writing to Unix domain sockets, when called from a graal native-image on MacOS, always writes 0 bytes.JNI call on native-image on MacOS gets argument passed always as 0 when it shouldn't be:
The final
jint
argumentcount
is always passed a0
. (note: the first jint argfd
is passed correctly)On MacOS the code works when running on the JVM, but fails when run as a native-image.
The code works on Linux, on both the JVM and as a native image.
Describe the full native-image command
Capture full native-image command by running with the `--verbose` flag e.g.:
Code snippet or code repository that reproduces the issue
I've setup a repo reducing the expression of the problem to the barest minimum.
Steps to reproduce the issue
Please include both build steps as well as run steps
Expected behavior
The test should pass. 14 bytes should be written to the socket. Instead 0 bytes are written.
Additional context
Add any other context about the problem here. Specially important are stack traces or log output. Feel free to link to gists or to screenshots if necesary
Details
The text was updated successfully, but these errors were encountered: