RFR: JDK-8277056: Combining several C2 Print* flags asserts in xmlStream::pop_tag [v2]

Tobias Holenstein duke at openjdk.java.net
Thu Apr 21 08:08:15 UTC 2022


> Sometimes the writing to xmlStream is mixed from several threads, and therefore the `xmlStream` tag stack can end up in a bad state. When this occurs, the VM crashes in `xmlStream::pop_tag` with `assert(false) failed: bad tag in log`.
> 
> The logging between `xtty->head` and `xtty->tail` is guarded by a ttyLocker which also locks `VMThread::should_terminate()` (ttyLocker is needed here to serializes the output info about the termination of the VMThread). 
> 
> The problem is that `print_metadata` and `dump_asm` may block for safepoint which then releases the ttyLocker (`break_tty_lock_for_safepoint`). When the `print_metadata` or `dump_asm` continues after the safepoint other threads could have taken the ttyLocker and may be busy printing and interfere with the tag stack of `xmlStream`.
> 
> The solution is to call `print_metadata` and `dump_asm` first and let them write to a local stringStream. Then acquire the ttyLocker to do the printing (using the local stringStream) and use a separate ttyLocker for `VMThread::should_terminate()`
> 
> The same issue was already targeted in https://bugs.openjdk.java.net/browse/JDK-8153527 but the fix was incomplete.

Tobias Holenstein has updated the pull request incrementally with one additional commit since the last revision:

  changed print to print_raw

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

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/8203/files
  - new: https://git.openjdk.java.net/jdk/pull/8203/files/81401140..9cb0ceab

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=8203&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=8203&range=00-01

  Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod
  Patch: https://git.openjdk.java.net/jdk/pull/8203.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/8203/head:pull/8203

PR: https://git.openjdk.java.net/jdk/pull/8203


More information about the hotspot-compiler-dev mailing list