On Thu, 18 Dec 2025 01:24:42 GMT, David Holmes <[email protected]> wrote:

> To ensure JNI critical access to a raw array can't interfere with actions of 
> the debugger, we disable JVM TI suspension whilst JNI critical access is 
> active, as originally suggested by @fisk. We assume the debugger is being 
> operated correctly (ie the thread using the raw array will be suspended), and 
> that the critical section is short so as to not delay debugging too long. 
> 
> The mechanism for this already exists courtesy of the virtual thread support.
> 
> Testing:
>  - tiers 1 - 6 sanity

FTR I don't think "returning a copy" is an option - as I tried to point out in 
the other JBS issue. It would have to be based on there being a debugger 
attached, but with dynamic attach for the debugger you'd have to wait for an 
existing critical region to complete when attaching. If we have to wait for 
something then probably better just to wait for the thread in the critical 
region that we are trying to suspend. But doing a busy-wait (`while 
(t->in_critical()) SpinYield()`) in `SuspendThreadHandshakeClosure` seems a bit 
hackish. I had hoped the "disable suspend" mechanism would be simple and 
elegant.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/28884#issuecomment-3673153689

Reply via email to