n2523: accessing const objects from signal handlers v2

Submitter:Philipp Klaus Krause
Submission Date:2020-05-11

Summary:

Allow access to const objects from signal handlers.

This proposal is an updated version of N2507, which followed up on N1812. N1812 was presented as a defect report and discussed at the 2014 Parma meeting. It was decided that a part of N1812 is a proposed normative change, not a defect. No follow-up happened on that part (the part considered a defect was fixed). This document proposes to make the normative change previously proposed as part of N1812 (with a slight modification to disallow accesses to const volatile objects and to thread-local objects). N2507 also proposed to allow acesses to non-volatile objects of thread storage duration, which has been removed in this version, since it would be hard to implement in glibc.

Justification:

The wording on signal handlers seems very restrictive. It disallows signal handlers to refer to most objects. However, refering to an object without accessing it (e.g. for use in sizeof or to take an address) could be allowed in signal handlers. Also reading const objects could be allowed.

Proposed changes (vs. the standard draft N2455):

Do we want to allow signal handlers to refer to objects, as long as the objects are not accessed?

In §7.14.1.1p5: Replace "the behavior is undefined if the signal handler refers to any object with static or thread storage duration that is not" by "the behavior is undefined if the signal handler accesses any object with static or thread storage duration that is not".

And make the corresponding change in §J.2.

Do we want to allow signal handlers to access const objects?

In §7.14.1.1p5: Replace "the behavior is undefined if the signal handler accesses any object with static or thread storage duration that is not a lock-free atomic object other than by assigning a value to an object declared as volatile sig_atomic_t " by "the behavior is undefined if the signal handler accesses any object with static or thread storage duration that is not a lock-free atomic object or a non-volatile const object of static storage duration other than by assigning a value to an object declared as volatile sig_atomic_t ".

And make the corresponding change in §J.2.