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
Thu Oct 16 16:13:01 UTC 2025
On Wed, 15 Oct 2025 12:24:04 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> 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.
>
> I was not sure how the "magic" of initialization worked in this case with default constructor arguments - plus I wanted to be explicit about the initial count. Unfortunately the template requires a reference hence the local was introduced - if there is a better way to do this please advise me.
There is a better way. `initialize` should use perfect forwarding. Sigh.
OK, leave it as is. It can be fixed later, once we allow perfect forwarding.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27762#discussion_r2436590698
More information about the hotspot-runtime-dev
mailing list