RFR: 8320652: ThreadInfo.isInNative needs to be updated to say what executing native code means [v2]

Bernd duke at openjdk.org
Tue Nov 28 14:32:23 UTC 2023


On Tue, 28 Nov 2023 06:15:54 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Note that there is no answer for the "syscall" case mentioned as it depends on the code that makes the syscall: if from a native method then yes; if from the VM then no.
>
>> Note that there is no answer for the "syscall" case mentioned as it depends on the code that makes the syscall: if from a native method then yes; if from the VM then no.
> 
> Right, if the thread invokes a Java native method then it may or may not invoke a system call, it doesn't matter, the ThreadInfo::isInNative method is just reporting a bit of thread state to say that it is in a native method. Same thing when calling a native function with the FFM API, the native function may be a syscall,  or the native code may invoke a syscall, it doesn't matter to ThreadInfo::isInNative as it just returns a bit of thread state.

btw for the following (system/native/runtime/embryotic) Reader thread tseems to be no java method marked "native" on the stack, what case is that?


"JDWP Event Helper Thread" #22 daemon prio=10 os_prio=0 cpu=0.00ms elapsed=65.02s tid=0x000001fc4f7e9970 nid=0x32e0 runnable  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"JDWP Command Reader" #23 daemon prio=10 os_prio=0 cpu=0.00ms elapsed=65.02s tid=0x000001fc4f7ea480 nid=0x69c4 runnable  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Notification Thread" #24 daemon prio=9 os_prio=0 cpu=0.00ms elapsed=64.99s tid=0x000001fc4f7f12a0 nid=0x75f0 runnable  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

jshell> mx.getThreadInfo(23)
$17 ==> "JDWP Command Reader" daemon prio=10 Id=23 RUNNABLE (in native)

funfact: its not in the list:


jshell> mx.getAllThreadIds()
$11 ==> long[8] { 1, 2, 3, 4, 5, 24, 25, 26 }

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16791#discussion_r1407852578


More information about the serviceability-dev mailing list