Help with VM Crash using the foreign linker
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Fri May 14 20:43:54 UTC 2021
Hi Duncan,
I haven't looked in any details at your email (but I will) - sounds like
a cool project. I wanted to share few early considerations:
* attachments are dropped by the openjdk mailer - so you need to post
them somewhere else (maybe make a Gist on Github?)
* For now, Java 16 and Java 17 have exactly the same code (since we have
not yet integrated Panama changes into 17). So you might want to try
again with e.g. the panama early access [1].
It would be helpful if we could see at least the logs of the crash. On
top of my head I can't think of any interaction between the Java
compiler API and the Foreign Linker API that would be causing this. And,
while there are many things that could go wrong when working with custom
class loaders, typically when things go wrong you end up with an
exception, not a VM crash.
But let's start from obtaining the logs, and maybe try to reproduce it,
and then let's figure out what's wrong.
Thanks for the report!
Maurizio
On 14/05/2021 21:20, Duncan McLean wrote:
> Hello,
>
> I'm sorry if this isn't the right place to be asking for help with the
> Foreign Linker, please let me know where I should direct this question if
> I'm in the wrong place.
>
> I'm using the Foreign Linker API in a project and experiencing an odd
> result. The project is available here:
>
> https://github.com/boulder-on/JPassport
>
> The way my code works is:
>
> Give JPassport an interface class that you would like to use with the
> Foreign Linker. JPassport writes the java code required to call the foreign
> library, compiles the code, and hands back an object that implements the
> interface and calls the foreign library. (I'm trying to mimic JNA like
> behaviour in terms of just providing an interface)
>
> The problem I'm seeing is in my test cases for passing data to functions
> requiring C structures
>
> test_jpassport/src/jpassport/test/structs/TestUsingStructs
>
> For some reason, any call to the foreign library causes the VM to crash.
> However, this only happens if I invoke the compiler. The 3 scenarios I've
> tested are:
>
> 1. Normal operation: write out a .java file, use JavaCompiler to compile,
> use URLClassloader to load the compiled class, call a foreign method ->
> crash.
>
> 2. Skip compiling: write out a .java file, do not compile, use URL
> Classloader to load the class compiled in the previous test, call a foreigh
> method -> no crash, the call works perfectly.
>
> 3. Compile manually: Take the java code written out in step 1, add it to my
> project, compile, run the program, call a foreign method -> no crash
>
> I've tested this with the most recent JDK 16, and the most recent JDK 17
> early access builds. My other test cases for passing primitives and arrays
> all work properly with the "normal operation".
>
> I'm testing using 64 bit VM's on Windows 10. I've attached one of the crash
> logs for further details on my set-up.
>
> Is there something I'm doing wrong? Please let me know if there are any
> other details I can provide or if there is any other way I can help
> diagnose what's going on.
>
> Thank you for your help,
> Duncan
More information about the panama-dev
mailing list