Bug of FFM implementation when creating upcalls accepting both structure and pointer parameters

Jorn Vernee jorn.vernee at oracle.com
Mon Jul 28 16:42:50 UTC 2025


The fix for this issue is included in the newest build of JDK 26. You 
can find it here:  https://jdk.java.net/26/

It would be great if you could test your code with that build to see if 
it fixes the issue for you as well.

Thanks,
Jorn

On 14-7-2025 15:10, Jorn Vernee wrote:
> Thanks for the report!
>
> I've filed: https://bugs.openjdk.org/browse/JDK-8362169
>
> Jorn
>
> On 14-7-2025 00:13, Chuigda Whitegive wrote:
>> Original StackOverflow question and answer: 
>> https://stackoverflow.com/a/79700269/14312575
>>   Brief: on Windows platform, when creating upcall stubs with FFM 
>> APIs, if the callback functions has both structure (larger than 
>> pointer size) and pointer parameters, the MemorySegments accepting 
>> these pointer parameters will be incorrectly linked with a confined 
>> memory session. Also, according to the answer of Jorn Vernee, this 
>> issue may also reproduce on platforms whose C ABI allocates structs 
>> that are passed by-value on the stack of the caller (AArch64 for 
>> example).
>>   The reproducer has been attached in the email.


More information about the panama-dev mailing list