RFR: JDK-8263871: On sem_destroy() failing we should assert

David Holmes dholmes at openjdk.java.net
Fri Mar 19 22:48:39 UTC 2021


On Fri, 19 Mar 2021 14:07:59 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

> This is rather trivial.
> 
> We use anonymous Posix semaphores for some synchronization in hotspot. `sem_destroy()` can fail on some platforms with EBUSY if the semaphore has outstanding waiters. The glibc does not care, will happily wipe the sem_t structure and report success. But other Unices care (eg BSD, AIX, HP-UX) and refuse to close the semaphore, leaving the sem_t structure untouched.
> 
> It then happened for us that a new semaphore was created at the exact location of the old, still unclosed semaphore, and the unchanged sem_t structure was fed to sem_init(), which would fail with the same EBUSY error and trigger a guarantee.
> 
> One simple thing we should do is to assert success after closing a semaphore, as we do on all other semaphore operations. Granted, we won't see anything on Linux with glibc, but maybe shake loose errors on other platforms.

Looks good and trivial.

I just hope we don't find sem_destroy has been silently failing :)

Thanks,
David

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

Marked as reviewed by dholmes (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/3089


More information about the hotspot-runtime-dev mailing list