RFR: 8369250: Assess and remedy any unsafe usage of the Semaphore used by NonJavaThread::List

David Holmes dholmes at openjdk.org
Tue Oct 7 07:15:49 UTC 2025


On Tue, 7 Oct 2025 06:33:29 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:

>> The `NonJavaThread::List` has a statically allocated instance which contains a `SingleWriterSynchronizer`, which contains a `Semaphore`. The `VMThread` can try to remove itself from the list after the static destructors have executed, leading to an assertion failure for the `Semaphore` but potentially it could crash as the `List` itself gets deallocated..  Simplest fix is to change the `List` instance to a `DeferredStatic` such that it is never destroyed.
>> 
>> Testing:
>>  - tiers 1-3 (sanity)
>> 
>> Thanks.
>
> src/hotspot/share/runtime/nonJavaThread.hpp line 49:
> 
>> 47:   }
>> 48: 
>> 49:   NonJavaThread* volatile _next;
> 
> Is there a reason why the code couldn't stay in the .cpp file?

Yes, we need a complete class definition of `T` available when we declare the `DeferredStatic<T>`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27664#discussion_r2409617594


More information about the hotspot-runtime-dev mailing list