[jdk17] RFR: 8269865: Async UL needs to handle ERANGE on exceeding SEM_VALUE_MAX [v3]

David Holmes david.holmes at oracle.com
Wed Jul 7 06:58:53 UTC 2021


On 7/07/2021 3:26 pm, Xin Liu wrote:
> On Wed, 7 Jul 2021 00:40:10 GMT, David Holmes <dholmes at openjdk.org> wrote:
> 
>> I'm surprised macOS has no overflow checks, it looks like its counter will just wrap when it overflows - which would break things, but of course is very unlikely in real use.
> 
> Unlike Posix and Win32, it's not easy for me to find any document about Darwin semaphore API.
> 
> I guess this is the equivalence of glibc on MacOS.  check out `semaphore_signal_internal`.
> https://opensource.apple.com/source/xnu/xnu-344.21.74/osfmk/kern/sync_sema.c.auto.html
> 
> if count has overflown, it should return kr from `wait_queue_wakeup64_thread_locked`.

You mean if count++ wraps around to become negative then the next call 
to signal will potentially execute that code? As the count++ happens 
after this that doesn't tell us anything about what happens to the 
signal that actually causes the overflow.

In any case due diligence has been done here. There is no documented 
error for overflow on macOS. A test for overflow failed to trigger any 
error within the test timeout period. I'm trying a modified test now to 
see if I can get any failure.

David

> -------------
> 
> PR: https://git.openjdk.java.net/jdk17/pull/216
> 


More information about the hotspot-runtime-dev mailing list