Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8285420

[LOOM] Some nsk/monitoring tests are failing due to lack of ThreadInfo support for vthreads

XMLWordPrintable

      The following nsk/monitoring tests are failing due to lack of ThreadInfo support for vthreads.

      vmTestbase/nsk/monitoring/ThreadInfo/isInNative/isinnative001/TestDescription.java
      vmTestbase/nsk/monitoring/ThreadInfo/getLockOwnerName/getlockownername001/TestDescription.java
      vmTestbase/nsk/monitoring/ThreadInfo/getLockName/getlockname001/TestDescription.java
      vmTestbase/nsk/monitoring/ThreadInfo/from_c/from_c001/TestDescription.java
      vmTestbase/nsk/monitoring/MemoryUsage/from/from001/TestDescription.java

      The following is for isinnative001:

      java.lang.NullPointerException: Cannot invoke "java.lang.management.ThreadInfo.isInNative()" because "<local6>" is null
      at nsk.monitoring.ThreadInfo.isInNative.isinnative001.run(isinnative001.java:40)
      at nsk.monitoring.ThreadInfo.isInNative.isinnative001.main(isinnative001.java:32)
      at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
      at java.base/java.lang.reflect.Method.invoke(Method.java:578)
      at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:142)
      at java.base/java.lang.VirtualThread.run(VirtualThread.java:287)
      at java.base/java.lang.VirtualThread$VThreadContinuation.lambda$new$0(VirtualThread.java:174)
      at java.base/jdk.internal.vm.Continuation.enter0(Continuation.java:327)
      at java.base/jdk.internal.vm.Continuation.enter(Continuation.java:320)

      getlockownername001, getlockname001, and from_c001 look similar, but the method that throws the NPE varies depending on which ThreadInfo methods is being called.

      The from001 failure is a bit differenct:

      # ERROR: FAILURE 2.
      The following stacktrace is for failure analysis.
      nsk.share.TestFailure: FAILURE 2.
      at nsk.share.Log.logExceptionForFailureAnalysis(Log.java:432)
      at nsk.share.Log.complain(Log.java:403)
      at nsk.monitoring.MemoryUsage.from.from001.run(from001.java:81)
      at nsk.monitoring.MemoryUsage.from.from001.main(from001.java:38)
      at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
      at java.base/java.lang.reflect.Method.invoke(Method.java:578)
      at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:142)
      at java.base/java.lang.VirtualThread.run(VirtualThread.java:287)
      at java.base/java.lang.VirtualThread$VThreadContinuation.lambda$new$0(VirtualThread.java:174)
      at java.base/jdk.internal.vm.Continuation.enter0(Continuation.java:327)
      at java.base/jdk.internal.vm.Continuation.enter(Continuation.java:320)
      # ERROR: MemoryUsage.from(CompositeData) returned null, expected: IllegalArgumentException.
      # ERROR: TEST FAILED

      I think the issue is that ThreadMXBean.getThreadInfo() returns null for virtual threads. Here's the relevant code for the isinnative001 test:

              ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
              Thread thread = Thread.currentThread();
              long id = thread.getId();
              ThreadInfo info = mbean.getThreadInfo(id, Integer.MAX_VALUE);
              boolean isInNative = info.isInNative();

      The test would need to be modified to expect a null ThreadInfo for virtual threads, but this essentially eliminates any real testing, so it really just shouldn't be run with the virtual thread wrapper.

            Unassigned Unassigned
            cjplummer Chris Plummer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: