RFR: 8356233: NMT: tty->print_cr should not be used in VirtualMemoryTracker::add_reserved_region()

Gerard Ziemski gziemski at openjdk.org
Tue May 20 15:56:01 UTC 2025


On Tue, 20 May 2025 06:56:16 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

>> To help with debugging NMT we added more info when an assert gets triggered, but we used `tty`, which is involved with locks and unfortunately it triggered:
>> 
>> 
>> # Internal Error (.../open/src/hotspot/share/runtime/mutex.cpp:457), pid=1088443, tid=1088520
>> # assert(false) failed: Attempting to acquire lock tty_lock/tty out of order with lock NmtVirtualMemory_lock/service-4 -- possible deadlock
>> 
>> 
>> We avoid this, by printing using `UL` instead of using `tty` directly.
>
> src/hotspot/share/nmt/virtualMemoryTracker.cpp line 404:
> 
>> 402:       }
>> 403: 
>> 404:       // Print some more details. Don't use UL here to avoid circularities.
> 
> It seems unlikely that any circularities would occur, as UL doesn't use the VMT.

I think so too. I forced the code to go through this path early in the VM init sequence and didn't see NMT activity.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25308#discussion_r2098327457


More information about the hotspot-runtime-dev mailing list