Bug 138081 - sem_post and sem_destroy fail to report errors
sem_post and sem_destroy fail to report errors
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: glibc (Show other bugs)
3.0
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-11-04 10:28 EST by Jared Smith-Mickelson
Modified: 2007-11-30 17:07 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-11-04 19:34:49 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
test case to illustrate the bug (1.88 KB, text/plain)
2004-11-04 10:30 EST, Jared Smith-Mickelson
no flags Details

  None (edit)
Description Jared Smith-Mickelson 2004-11-04 10:28:59 EST
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; 
SV1; .NET CLR 1.1.4322)

Description of problem:
According to the man page, sem_post should return -1 and set errno to 
ERANGE if after incrementation, the semaphore value would exceed 
SEM_VALUE_MAX.  sem_post instead returns 0 in this case.  Similarly, 
sem_destroy should return -1 and set errno to EBUSY if any threads 
are currently blocked waiting on the semaphore.  It instead returns 0 
in this case.

Version-Release number of selected component (if applicable):
glibc-2.3.2-95.27

How reproducible:
Always

Steps to Reproduce:
1.  cc -lpthread sembug.c -o sembug
2.  ./sembug

Actual Results:  Test 1: sem_post should return -1 and set errno to 
ERANGE if
        after incrementation, the semaphore value would exceed
        SEM_VALUE_MAX.

        failed - return value was 0 not -1

Test 2: sem_destroy should return -1 and set errno to EBUSY if
        any threads are currently blocked waiting on the
        semaphore.

        failed - return value was 0 not -1

Expected Results:  Test 1: sem_post should return -1 and set errno to 
ERANGE if
        after incrementation, the semaphore value would exceed
        SEM_VALUE_MAX.

        passed

Test 2: sem_destroy should return -1 and set errno to EBUSY if
        any threads are currently blocked waiting on the
        semaphore.

        passed


Additional info:
Comment 1 Jared Smith-Mickelson 2004-11-04 10:30:09 EST
Created attachment 106167 [details]
test case to illustrate the bug
Comment 2 Jakub Jelinek 2004-11-04 15:39:52 EST
The man page is for LinuxThreads.
NPTL is governed by POSIX and there is no such requirement in
http://www.opengroup.org/onlinepubs/009695399/functions/sem_post.html
(only sem_open must return SEM_FAILED + EINVAL in errno if 4th argument is > SEM_VALUE_MAX).
Similarly,
http://www.opengroup.org/onlinepubs/009695399/functions/sem_destroy.html
doesn't mandate but allows -1/EBUSY in sem_destroy.
Comment 3 Roland McGrath 2004-11-04 19:34:49 EST
Indeed, no bugs here.

Note You need to log in before you can comment on or make changes to this bug.