Summary: | Bad semaphore return code on collision | ||
---|---|---|---|
Product: | Base System | Reporter: | karl |
Component: | kern | Assignee: | Jilles Tjoelker <jilles> |
Status: | Closed FIXED | ||
Severity: | Affects Many People | CC: | jilles |
Priority: | --- | Flags: | jilles:
mfc-stable10+
|
Version: | 10.2-STABLE | ||
Hardware: | Any | ||
OS: | Any |
Description
karl
2016-02-04 18:38:30 UTC
The additional [EINVAL] condition is missing from the semget(2) man page; I will add it. Although POSIX leaves the detection order of errors undefined (XSH 2.3 Error Numbers), detecting [EINVAL] before [EEXIST] is clearly inconvenient for applications. The inconvenient order has been in place for years, but it is easy to change. You could request the Austin Group to make this unambiguous (e.g., restrict part of the [EINVAL] error to not occur if ((semflg&IPC_CREAT)&&(segflg&IPC_EXCL)) is non-zero). A commit references this bug: Author: jilles Date: Sun Feb 7 21:25:08 UTC 2016 New revision: 295384 URL: https://svnweb.freebsd.org/changeset/base/295384 Log: semget(2): Add missing [EINVAL] conditions. PR: 206927 Changes: head/lib/libc/sys/semget.2 A commit references this bug: Author: jilles Date: Sun Feb 7 22:12:39 UTC 2016 New revision: 295385 URL: https://svnweb.freebsd.org/changeset/base/295385 Log: semget(): Check for [EEXIST] error first. Although POSIX literally permits failing with [EINVAL] if IPC_CREAT and IPC_EXCL were both passed, the semaphore set already exists and has fewer semaphores than nsems, this does not allow an application to retry safely: if the [EINVAL] is actually because of the semmsl limit, an infinite loop would result. PR: 206927 Changes: head/sys/kern/sysv_sem.c head/tools/regression/sysvsem/semtest.c Fixed in head two weeks ago. I plan to MFC to stable/10 after 10.3-RELEASE. A commit references this bug: Author: jilles Date: Fri Apr 8 15:43:49 UTC 2016 New revision: 297719 URL: https://svnweb.freebsd.org/changeset/base/297719 Log: MFC r295384: semget(2): Add missing [EINVAL] conditions. PR: 206927 Changes: _U stable/10/ stable/10/lib/libc/sys/semget.2 A commit references this bug: Author: jilles Date: Sat Apr 9 13:32:42 UTC 2016 New revision: 297747 URL: https://svnweb.freebsd.org/changeset/base/297747 Log: MFC r295385: semget(): Check for [EEXIST] error first. Although POSIX literally permits failing with [EINVAL] if IPC_CREAT and IPC_EXCL were both passed, the semaphore set already exists and has fewer semaphores than nsems, this does not allow an application to retry safely: if the [EINVAL] is actually because of the semmsl limit, an infinite loop would result. PR: 206927 Changes: _U stable/10/ stable/10/sys/kern/sysv_sem.c stable/10/tools/regression/sysvsem/semtest.c |