GetLastError() (with and without debugger)
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Fri Aug 12 15:36:38 UTC 2022
On 12/08/2022 16:13, Thomas Stüfe wrote:
> Stupid question, since those calls are embedded into java code, can
> this really be prevented? E.g. thread allocates object -> causes heap
> to expand -> needs commit -> calls VirtualAlloc?
VirtualAlloc (and other os specific routines) are using the
PreserveLastError mechanism. I doubt the VM is causing this (in fact
this works reliably w/o debugger).
>
> I would have thought that you need to treat GetLastError special. JNA
> seems to do this:
> https://github.com/java-native-access/jna/blob/999c60a1fa0ab1154b07edffa3748ce46d8d3b89/src/com/sun/jna/NativeLibrary.java#L130
> <https://urldefense.com/v3/__https://github.com/java-native-access/jna/blob/999c60a1fa0ab1154b07edffa3748ce46d8d3b89/src/com/sun/jna/NativeLibrary.java*L130__;Iw!!ACWV5N9M2RV99hQ!NWK1fBgnKORxT1DxxqZUDYS8q6cpWFtkYT-ZAvza_QQZhDy60oq-_IL3t5bN2z0NqpsM_5Bmhser_482CIZi2lkCeVarA68$>
I see, JNA saves this value after the call:
https://github.com/java-native-access/jna/blob/master/native/dispatch.c#L681
JNR seems to have something similar:
https://github.com/jnr/jffi/blob/39cfdaff1b7882823dd21f17a11ca68fbf974a92/jni/jffi/CallContext.h#L59
That said, I'd expect JNI to still fail in a similar way (unless the
call and the check occur in the same call).
Maurizio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20220812/25546c4f/attachment.htm>
More information about the panama-dev
mailing list