RFR: 8369631: Assess and remedy any unsafe usage of the sr_semaphore Semaphore in the Posix signal code
Kim Barrett
kbarrett at openjdk.org
Tue Oct 14 17:23:18 UTC 2025
On Tue, 14 Oct 2025 08:59:02 GMT, Kim Barrett <kbarrett 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.
>
> src/hotspot/os/posix/signals_posix.cpp line 172:
>
>> 170: static OSXSemaphore* sr_semaphore;
>> 171: #else
>> 172: static PosixSemaphore* sr_semaphore;
>
> pre-existing: Why is this conditionalized, rather than just using `Semaphore` (which is already being used
> for `sig_semaphore`)?
Oops, I see why this is being done. The code in this file calls `timedwait` on
the semaphore, but `Semaphore` for some reason doesn't provide that operation.
It seems that's always been true, since the introduction of `Semaphore`,
because "it wasn't needed". But that forces conditionalization like this. Sigh.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27762#discussion_r2429920395
More information about the hotspot-runtime-dev
mailing list