Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0000841 [1003.1(2008)/Issue 7] System Interfaces Objection Enhancement Request 2014-05-29 16:25 2024-06-11 08:52
Reporter nick View Status public  
Assigned To ajosey
Priority normal Resolution Accepted As Marked  
Status Closed  
Name Rich Felker
Organization musl libc
User Reference
Section XSH 2.4.3 Signal Actions
Page Number 489
Line Number 16722-16755
Interp Status ---
Final Accepted Text see Note: 0002262
Summary 0000841: pthread_setcancelstate should be async-signal-safe
Description ISSUE 8 CHANGES, cloned from 0000615

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).
Desired Action At page 489 lines 16722-16755 (XSH 2.4.3) insert:

pthread_setcancelstate()

After applying the changes from 0000615, at page 489 line 16756 (XSH 2.4.3 Signal Actions), change:

Implementations may make other interfaces async-signal-safe.

to:

It is implementation-defined which additional interfaces, if any, are also async-signal-safe.

At page 515 line 17840 section 2.9.5.4 Async-Cancel Safety add two paragraphs:

If a thread has asynchronous cancellation enabled and is cancelled during execution of a function that is not async-cancel-safe, the behavior is undefined.

If a thread has deferred cancellation enabled, a signal catching function is called in that thread during execution of a function that is not async-cancel-safe, and the signal catching function calls any function that is a cancellation point while a cancellation is pending for the thread, without first disabling cancellation, the behavior is undefined.

At page 1694 after line 54312 (XSH pthread_setcancelstate() description) insert a new paragraph:

The pthread_setcancelstate() function shall be async-signal-safe.

After applying the changes in 0000615, 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.

to:

None.
Tags issue8
Attached Files

- Relationships
related to 0000622Closedajosey Disallow loophole for asynchronous cancellation of any function 
child of 0000615Closedajosey pthread_setcancelstate should be async-signal-safe 

-  Notes
(0002255)
geoffclare (manager)
2014-05-30 08:36

I have edited the desired action to correct the page and line number for section 2.9.5.4.
(0002262)
nick (manager)
2014-06-05 15:46
edited on: 2014-06-05 15:55

At page 489 lines 16722-16755 (XSH 2.4.3) insert:

pthread_setcancelstate()

After applying the changes from 0000615, at page 489 line 16756 (XSH 2.4.3 Signal Actions), change:

Implementations may make other interfaces async-signal-safe.

to:

It is implementation-defined which additional interfaces, if any, are also async-signal-safe.


After applying the changes from 0000622, at page 515 line 17840 section 2.9.5.4 Async-Cancel Safety, change:

If a thread has deferred cancellation enabled, a signal catching function is called in that thread during execution of a function that is not async-cancel-safe, and the signal catching function calls any function that is a cancellation point while a cancellation is pending for the thread, the behavior is undefined.

to:

If a thread has deferred cancellation enabled, a signal catching function is called in that thread during execution of a function that is not async-cancel-safe, and the signal catching function calls any function that is a cancellation point while a cancellation is pending for the thread, without first disabling cancellation, the behavior is undefined.

After applying the changes from 0000622, at page 1694 line 54327 (pthread_setcancelstate() application usage), change:

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 permit strictly conforming applications to call pthread_setcancelstate() from a signal handler since it is not currently required to be async-signal-safe. On implementations where pthread_setcancelstate() is not async-signal-safe, alternatives are to ensure either that the corresponding signals are blocked during execution of functions that are not async-cancel-safe or that cancellation is disabled during times when those signals could be delivered. Implementations are strongly encouraged to make pthread_setcancelstate() async-signal-safe.

to:

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, earlier versions of the standard did not permit strictly conforming applications to call pthread_setcancelstate() from a signal handler since it was not required to be async-signal-safe. On non-conforming implementations where pthread_setcancelstate() is not async-signal-safe, alternatives are to ensure either that the corresponding signals are blocked during execution of functions that are not async-cancel-safe or that cancellation is disabled during times when those signals could be delivered.

(keep first sentence, change second and third sentences, delete fourth sentence).

At page 1694 after line 54312 (XSH pthread_setcancelstate() description) insert a new paragraph:

The pthread_setcancelstate() function shall be async-signal-safe.

After applying the changes in 0000615, 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.

to:

None.



- Issue History
Date Modified Username Field Change
2014-05-29 16:25 nick New Issue
2014-05-29 16:25 nick Status New => Under Review
2014-05-29 16:25 nick Assigned To => ajosey
2014-05-29 16:25 nick Name => Rich Felker
2014-05-29 16:25 nick Organization => musl libc
2014-05-29 16:25 nick Section => XSH 2.4.3 Signal Actions
2014-05-29 16:25 nick Page Number => 489
2014-05-29 16:25 nick Line Number => 16722-16755
2014-05-29 16:25 nick Interp Status => ---
2014-05-29 16:25 nick Issue generated from 0000615
2014-05-29 16:25 nick Relationship added child of 0000615
2014-05-29 16:27 nick Tag Attached: issue8
2014-05-29 16:27 nick Resolution Open => Accepted
2014-05-29 16:28 nick Status Under Review => Resolved
2014-05-29 16:31 nick Desired Action Updated
2014-05-29 16:32 nick Desired Action Updated
2014-05-30 08:36 geoffclare Note Added: 0002255
2014-05-30 08:36 geoffclare Desired Action Updated
2014-06-05 14:48 geoffclare Relationship added related to 0000622
2014-06-05 15:46 nick Note Added: 0002262
2014-06-05 15:48 nick Final Accepted Text => see Note: 0002262
2014-06-05 15:48 nick Resolution Accepted => Accepted As Marked
2014-06-05 15:52 nick Note Edited: 0002262
2014-06-05 15:55 nick Note Edited: 0002262
2020-03-27 16:35 geoffclare Status Resolved => Applied
2024-06-11 08:52 agadmin Status Applied => Closed


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker