Bug 138081 - sem_post and sem_destroy fail to report errors
Summary: sem_post and sem_destroy fail to report errors
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: glibc   
(Show other bugs)
Version: 3.0
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-11-04 15:28 UTC by Jared Smith-Mickelson
Modified: 2007-11-30 22:07 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-11-05 00:34:49 UTC
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 15:30 UTC, Jared Smith-Mickelson
no flags Details

Description Jared Smith-Mickelson 2004-11-04 15:28:59 UTC
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 15:30:09 UTC
Created attachment 106167 [details]
test case to illustrate the bug

Comment 2 Jakub Jelinek 2004-11-04 20:39:52 UTC
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-05 00:34:49 UTC
Indeed, no bugs here.



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