RFR: 8347408: Create an internal method handle adapter for system calls with errno [v6]
Alan Bateman
alanb at openjdk.org
Tue Jan 14 08:52:40 UTC 2025
On Tue, 14 Jan 2025 07:31:08 GMT, Per Minborg <pminborg at openjdk.org> wrote:
>> src/java.base/share/classes/jdk/internal/foreign/CaptureStateUtil.java line 214:
>>
>>> 212: // Used reflectively by `getAsIntHandle(MemoryLayout layout)`
>>> 213: private static int getStateAsInt(VarHandle handle) {
>>> 214: if (Thread.currentThread().isVirtual() && ContinuationSupport.isSupported()) {
>>
>> Shouldn't we pin for the entire duration of the native call + errno retrieval? Otherwise, can't we end up in a situation where we have a back to back native call where the second native call overwrites the errno state of the first?
>
> True. We need to rework the solution a bit as we do not want to pin virtual threads during system calls.
A virtual thread can't unmount when there is a native frame on the continuation stack so it's pinned when in the syscall. For the errno capture then I think it will need to explicitly pin before the syscall, then unpin after the capture. The only access to the carrier local will be while pinned.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22391#discussion_r1914451688
More information about the core-libs-dev
mailing list