RFR: 8358568: C2 compilation hits "must have a monitor" assert with -XX:-GenerateSynchronizationCode
Dean Long
dlong at openjdk.org
Thu Jul 3 02:17:38 UTC 2025
On Thu, 3 Jul 2025 01:59:55 GMT, hanguanqiang <duke at openjdk.org> wrote:
> This PR fixes JDK-8358568, a JVM crash triggered when running with -XX:-GenerateSynchronizationCode
>
> Problem:
> When synchronization code generation is disabled by -XX:-GenerateSynchronizationCode, the compiler’s do_monitor_exit() method still tries to access monitor objects without checking if any monitors exist.This causes an assertion failure and JVM crash.
>
> Root Cause:
> Parse::do_monitor_exit() calls shared_unlock() using monitor info unconditionally,but with GenerateSynchronizationCode disabled, no monitor info is available, leading to invalid access.
>
> Fix
> Add a check in do_monitor_exit() to skip monitor unlocking if GenerateSynchronizationCode is false, avoiding invalid monitor access and preventing the crash.
I don't see the point of trying to support this flag. Can we just get rid of it? I don't think it is ever tested, because testing would surely crash unless the JVM ran as single-threaded somehow, which it doesn't. Maybe at some point this flag was useful for getting a new port limping along, but I think stubbing sync code would work just as well.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/26108#issuecomment-3030292214
More information about the hotspot-compiler-dev
mailing list