The jcmd might crash while calling ThreadSnapshot.of() for thread that have 
monitors.

Originally, the jcmd crashed while calling by jtreg timeout failure handler for 
test `compiler/c2/Test6603011.java` while it was executed with 
`-XX:+StressBailout`. The `-XX:+StressBailout` is not related to crash, just 
cause test timeout. 

The main cause of crash is that test was executed with `-Xcomp -XX:-Inline`. 
See:
 * @run main/othervm/timeout=480 -Xcomp -Xbatch -XX:-Inline 
compiler.c2.Test6603011

That provokes the access to uninitialized ThreadSnapshot$ThreadLock class.

The ThreadSnapshot has a field
`private ThreadLock[] locks;`
that is initialized by VM native code.

The corresponding class is not initialized during this creation. 

The `-XX:CompileCommand=compileonly,*ThreadSnapshot*::*` in test is required 
only to optimize execution. It fails without it as well.

---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

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

Commit messages:
 - restored removed line
 - better fix
 - 8378071 jcmd ThereadDump crashes with 
assert(!InstanceKlass::cast(receiver_klass)->is_not_initialized()) failed: 
receiver_klass must be

Changes: https://git.openjdk.org/jdk/pull/32362/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=32362&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8378071
  Stats: 47 lines in 2 files changed: 47 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/32362.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/32362/head:pull/32362

PR: https://git.openjdk.org/jdk/pull/32362

Reply via email to