RFR: 8313081: MonitoringSupport_lock should be unconditionally initialized after 8304074
Aleksey Shipilev
shade at openjdk.org
Wed Jul 26 10:47:42 UTC 2023
On Tue, 25 Jul 2023 21:48:24 GMT, Paul Hohensee <phh at openjdk.org> wrote:
> MonitoringSupport_lock is initialized only when UseG1GC is true, but [JDK-8304074](https://bugs.openjdk.org/browse/JDK-8304074) uses it to implement getTotalThreadAllocatedBytes, which is available for all garbage collectors. While the current code sets UseG1GC regardless of which collector is specified, see FLAG_SET_ERGO_IF_DEFAULT(UseG1GC, true) in gcConfig.cpp, if G1 isn't included in the Hotspot build or Hotspot is not running on a server class machine (unlikely these days), the lock will not be initialized. The lock's initialization should be unconditional.
>
> I updated ThreadAllocatedMemory.java to run the test using both G1 and Serial collectors.
So... this does not visibly break right now, because the `MutexLocker` in `jmm_GetTotalThreadAllocatedMemory` silently accepts `nullptr` as the lock? I think we should `assert(MonitoringSupport_lock != nullptr)` there. This should also turn the new `UseSerialGC` test config into proper regression test: the test should fail on that assert without this patch.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/15028#issuecomment-1651533398
More information about the serviceability-dev
mailing list