View Issue Details

IDProjectCategoryView StatusLast Update
00008701003.1(2013)/Issue7+TC1System Interfacespublic2019-06-10 08:54
Reporterdalias Assigned To 
PrioritynormalSeverityEditorialTypeClarification Requested
Status ClosedResolutionAccepted As Marked 
NameRich Felker
Organizationmusl libc
User Reference
Sectionsem_close
Page Number1827
Line Number58866
Interp StatusApproved
Final Accepted Text0000870:0002399
Summary0000870: Can sem_close be called when there are waiters blocked?
DescriptionThe description of sem_close states "The effect of subsequent use of the semaphore indicated by sem by this process is undefined", but no mention is made of what happens when there are currently waiters. Since the state of a thread about to enter sem_wait pending being scheduled is observably indistinguishable from the state of already having entered sem_wait and blocked, I think the above text makes it acceptable for an implementation to crash or exhibit unexpected behavior if sem_close is called while there are waiters, but it would be preferable to make this explicit.
Desired ActionImmediately after:

"The effect of subsequent use of the semaphore indicated by sem by this process is undefined."

add:

"If any threads are currently blocked on the semaphore, the behavior is undefined."
Tagstc2-2008

Activities

dalias

2014-08-25 18:44

reporter   bugnote:0002364

That should read "If any threads in the calling process are currently blocked on the semaphore, the behavior is undefined." Obviously it's permitted to close a semaphore for which other processes have waiters. Presumably it's also permitted to close a semaphore which the current process is still using as long as the reference count will not reach zero, but the reference-counted behavior of named semaphores is not even mentioned in the description of sem_close (only sem_open); this seems to be another error in the description.

geoffclare

2014-10-02 16:13

manager   bugnote:0002399

Interpretation response
------------------------

The standard does not speak to this issue, and as such no conformance
distinction can be made between alternative implementations based on
this. This is being referred to the sponsor.

Rationale:
-------------

There are current implementations which return mmap()ed memory and therefore a sem_close() in this situation on such implementations will result in undefined behavior.

Notes to the Editor (not part of this interpretation):
-------------------------------------------------------

On page 1827 line 58866 after:

    The effect of subsequent use of the semaphore indicated by sem by this process is undefined.

add:

    If any threads in the calling process are currently blocked on the semaphore, the behavior is undefined.

ajosey

2014-10-06 07:44

manager   bugnote:0002404

Interpretation proposed 6 October 2014

ajosey

2014-11-27 10:31

manager   bugnote:0002445

Interpretation approved 27 November 2014

Issue History

Date Modified Username Field Change
2014-08-25 18:11 dalias New Issue
2014-08-25 18:11 dalias Name => Rich Felker
2014-08-25 18:11 dalias Organization => musl libc
2014-08-25 18:11 dalias Section => sem_close
2014-08-25 18:11 dalias Page Number => unknown
2014-08-25 18:11 dalias Line Number => unknown
2014-08-25 18:44 dalias Note Added: 0002364
2014-10-02 16:13 geoffclare Note Added: 0002399
2014-10-02 16:14 geoffclare Page Number unknown => 1827
2014-10-02 16:14 geoffclare Line Number unknown => 58866
2014-10-02 16:14 geoffclare Interp Status => Pending
2014-10-02 16:14 geoffclare Final Accepted Text => 0000870:0002399
2014-10-02 16:14 geoffclare Status New => Interpretation Required
2014-10-02 16:14 geoffclare Resolution Open => Accepted As Marked
2014-10-02 16:14 geoffclare Tag Attached: tc2-2008
2014-10-06 07:44 ajosey Interp Status Pending => Proposed
2014-10-06 07:44 ajosey Note Added: 0002404
2014-11-27 10:31 ajosey Interp Status Proposed => Approved
2014-11-27 10:31 ajosey Note Added: 0002445
2019-06-10 08:54 agadmin Status Interpretation Required => Closed