|Anonymous | Login | Signup for a new account||2017-03-28 13:55 UTC|
|Main | My View | View Issues | Change Log | Docs|
|Viewing Issue Simple Details|
|ID||Category||Severity||Type||Date Submitted||Last Update|
|0000615||[1003.1(2008)/Issue 7] System Interfaces||Editorial||Enhancement Request||2012-09-26 02:32||2014-08-05 13:17|
|Priority||normal||Resolution||Accepted As Marked|
|Section||XSH 2.4.3 Signal Actions|
|Final Accepted Text||See Note: 0002254|
|Summary||0000615: pthread_setcancelstate should be async-signal-safe|
In order to write a signal handler for an asynchronous signal which can run safely in a cancellable thread, pthread_setcancelstate must be used to disable cancellation for the duration of the signal handler. This is because acting on cancellation at a cancellation point that occurs during a signal handler is, from the perspective of the asynchronously interrupted code, asynchronous cancellation.
Consider for example the case where the main flow of execution of the thread is in malloc at the time a signal arrives, and the signal handler calls an async-signal-safe function which is also a cancellation point (such as open/close).
Add pthread_setcancelstate to the list of async-signal-safe functions, with notes to the effect that if a signal handler invokes cancellation points and may be invoked in a thread that is the target of cancellation, the application shall ensure either that the signal handler cannot interrupt any function which is not async-cancel-safe, or that pthread_setcancelstate is used to prevent cancellation from being acted upon in the signal handler.
If this is not acceptable, then application usage notes should be added to the effect that cancellable threads shall avoid executing signal handlers which could invoke cancellation points, either by blocking all signals in the thread or by assuring that no signal handler which invokes cancellation points has been installed.
Mark: AIX appears to be async-signal-safe.
Andrew reports Apple: not async-signal-safe, but not pthreads conforming so may not be relevant.
|pthread_setcancelstate is async-signal-safe in Solaris.|
For the record we also had this response from HP on 2013-06-07:
The routine pthread_setcancelstate() is *not* async-signal-safe on HPUX
NetBSD's pthread_setcancelstate() is not async-signal-safe:
Don Cragun (manager)
edited on: 2014-05-29 16:34
The standard states that when a thread's cancelability state is PTHREAD_CANCEL_DEFERRED, cancellation requests are held pending until a cancellation point is reached, and conforming implementations must conform to this. However, concerns have been raised about this which are being referred to the sponsor (some cancellation points may be reached in an asynchronous signal handler because some cancellation points are in async-signal-safe functions).
In order to write a signal handler for an asynchronous signal which can run safely in a cancellable thread, pthread_setcancelstate() must be used to disable cancellation for the duration of any calls that the signal handler makes which are cancellation points. However, the standard does not currently permit strictly conforming applications to do this since pthread_setcancelstate() is not required to be async-signal-safe.
Notes to the Editor (not part of this interpretation):
At page 489 line 16756 (XSH 2.4.3 Signal Actions), change:
All functions not in the above table are considered to be unsafe with respect to signals.
Any function not in the above table may be unsafe with respect to signals. Implementations may make other interfaces async-signal-safe.
At page 1695 line 54349 (XSH pthread_setcancelstate() future directions), change:
The pthread_setcancelstate() function may be added to the table of async-signal-safe functions in section 2.4.3 on page 489.
|Interpretation proposed June 27 2014|
|Interpretation approved 5 August 2014|
|2012-09-26 02:32||dalias||New Issue|
|2012-09-26 02:32||dalias||Status||New => Under Review|
|2012-09-26 02:32||dalias||Assigned To||=> ajosey|
|2012-09-26 02:32||dalias||Name||=> Rich Felker|
|2012-09-26 02:32||dalias||Organization||=> musl libc|
|2012-09-26 02:32||dalias||Section||=> XSH 2.4.3 Signal Actions|
|2012-09-26 02:32||dalias||Page Number||=> unknown|
|2012-09-26 02:32||dalias||Line Number||=> unknown|
|2013-04-25 16:19||Don Cragun||Relationship added||related to 0000622|
|2013-05-23 15:11||msbrown||Note Added: 0001623|
|2013-05-30 14:24||jim_pugsley||Note Added: 0001628|
|2014-05-22 16:14||geoffclare||Note Added: 0002249|
|2014-05-23 04:15||rhansen||Note Added: 0002250|
|2014-05-29 16:24||Don Cragun||Interp Status||=> ---|
|2014-05-29 16:24||Don Cragun||Note Added: 0002254|
|2014-05-29 16:24||Don Cragun||Status||Under Review => Interpretation Required|
|2014-05-29 16:24||Don Cragun||Resolution||Open => Accepted As Marked|
|2014-05-29 16:25||nick||Issue cloned||0000841|
|2014-05-29 16:25||nick||Relationship added||parent of 0000841|
|2014-05-29 16:26||Don Cragun||Page Number||unknown => 489|
|2014-05-29 16:26||Don Cragun||Line Number||unknown => 16756|
|2014-05-29 16:26||Don Cragun||Interp Status||--- => Pending|
|2014-05-29 16:26||Don Cragun||Final Accepted Text||=> See Note: 0002254|
|2014-05-29 16:27||geoffclare||Tag Attached: tc2-2008|
|2014-05-29 16:34||Don Cragun||Note Edited: 0002254|
|2014-06-27 11:09||ajosey||Interp Status||Pending => Proposed|
|2014-06-27 11:09||ajosey||Note Added: 0002290|
|2014-08-05 13:17||ajosey||Interp Status||Proposed => Approved|
|2014-08-05 13:17||ajosey||Note Added: 0002330|
|Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group|