RFR: 8369631: Assess and remedy any unsafe usage of the sr_semaphore Semaphore in the Posix signal code [v2]

Kim Barrett kbarrett at openjdk.org
Wed Oct 15 02:10:03 UTC 2025


On Wed, 15 Oct 2025 01:27:37 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Replace the statically allocated "semaphore" with a pointer and lazily initialize it. I chose this approach as we already have a second Semaphore declared that way.
>> 
>> Testing:
>> - tiers 1-3 sanity
>> 
>> Thanks.
>
> David Holmes has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Switch to DeferredStatic per Kim's request

src/hotspot/os/posix/signals_posix.cpp line 356:

> 354:   // Initialize signal semaphore
> 355:   int sem_count = 0;
> 356:   sig_semaphore.initialize(sem_count);

Just `sig_semaphore.initialize();` should be work. And the variable declaration looks kind of odd in context.

src/hotspot/os/posix/signals_posix.cpp line 363:

> 361:     // initialization isn't called. This code is also never called.
> 362:     assert(!ReduceSignalUsage, "Should not reach here if ReduceSignalUsage is set");
> 363: 

Even better than my suggestion.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27762#discussion_r2430923042
PR Review Comment: https://git.openjdk.org/jdk/pull/27762#discussion_r2430920380


More information about the hotspot-runtime-dev mailing list