Help with VM Crash using the foreign linker

Maurizio Cimadamore maurizio.cimadamore at
Mon May 17 11:53:53 UTC 2021

On 16/05/2021 01:27, Duncan McLean wrote:
> Hi Jorn,
> Thank you for the suggestion. I've looked into this and the 
> FunctionDescriptor is exactly as you have suggested: 
>  FunctionDescriptor.of(C_DOUBLE, C_POINTER).

Are you sure that's the correct descriptor? Looking at the definition of 

It seems like the struct is being passed by value? Or, when a method in 
JPassport is defined to take a struct Foo, you always imply Foo* - e.g. 
pass the struct by pointer? If that's the case, then I think the 
function descriptor is correct.


> I went so far as to hard code FunctionDescriptor call when I was 
> running my TestUsingStructs test case. The FunctionDescriptor is build at:
> <*L89__;Iw!!GqivPVa7Brio!LGQVZQLZaKulviK8dN2_jjzVrSssd7ygBA_DkDCRPabfkoDT_UJQ2VmAA5shdr99KgWThnU$>
> For some reason I can only run my test cases from my IDE, maven 
> doesn't like something I'm doing (right now it finds my test classes, 
> but no test cases). However, when run from the IDE, 
> TestUsingStructs crashes the vm every time on the first invokeExact 
> call it encounters. When I comment out the deleting of previously 
> compiled files and the compiling of new files (such that the test runs 
> with the last compiled version) the test case always works.
> Line for deleting previous compiles:
> <*L535__;Iw!!GqivPVa7Brio!LGQVZQLZaKulviK8dN2_jjzVrSssd7ygBA_DkDCRPabfkoDT_UJQ2VmAA5shdr99dD1D-Kg$>
> Line for compiling new classes:
> <*L551__;Iw!!GqivPVa7Brio!LGQVZQLZaKulviK8dN2_jjzVrSssd7ygBA_DkDCRPabfkoDT_UJQ2VmAA5shdr99UqpjNWk$>
> Is there any more detailed logging I can generate?
> Thanks again,
> Duncan
> On Sat, May 15, 2021 at 9:36 AM Jorn Vernee <jorn.vernee at 
> <mailto:jorn.vernee at>> wrote:
>     Hi,
>     Looking at the crash log, as well as the test, you seem to be
>     passing a
>     single struct to a native function, but the stack trace in the
>     error log
>     shows that the call is not being intrinsified, which should not be
>     the
>     case if you're only passing a single struct on Windows. Either it
>     fits
>     in a register, or it's passed by reference, both of which cases are
>     intrinsified.
>     The most likely explanation for that seems to be that you are not
>     using
>     the right FunctionDescriptor when linking, and a crash occurs when
>     the
>     native code is trying to access what it thinks is a pointer to a
>     struct.
>     This is undefined behavior territory, which could explain why the
>     crash
>     only occurs in certain scenarios.
>     My advice would be to check the FunctionDescriptor you're using
>     for the
>     linkage request, and make sure it matches the native function
>     declaration. Looking at [1], the FunctionDescriptor you need is
>     FunctionDescriptor.of(C_DOUBLE, C_POINTER).
>     HTH,
>     Jorn
>     [1] :
>     <*L330__;Iw!!GqivPVa7Brio!LGQVZQLZaKulviK8dN2_jjzVrSssd7ygBA_DkDCRPabfkoDT_UJQ2VmAA5shdr99mEQo5Qw$>

More information about the panama-dev mailing list