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

Thomas Stuefe stuefe at openjdk.java.net
Sat Mar 20 05:54:43 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.

This pull request has now been integrated.

Changeset: 5b8233ba
Author:    Thomas Stuefe <stuefe at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/5b8233ba
Stats:     2 lines in 1 file changed: 1 ins; 0 del; 1 mod

8263871: On sem_destroy() failing we should assert

Reviewed-by: dholmes

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

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


More information about the hotspot-runtime-dev mailing list