Menu

#65 Accesses to non-volatile non-atomic globals in signal handler context

v1.0 (example)
open
nobody
None
5
2021-02-16
2021-02-16
No

All signal handlers are accessing non-volatile non-atomic globals. This is undefined behavior according to the C99 standard (7.14.1):

  1. If the signal occurs other than as the result of calling the abort or raise function, the
    behavior is undefined if the signal handler refers to any object with static storage duration
    other than by assigning a value to an object declared as volatile sig_atomic_t, or
    the signal handler calls any function in the standard library other than the abort
    function, the _Exit function, or the signal function with the first argument equal to
    the signal number corresponding to the signal that caused the invocation of the handler.
    Furthermore, if such a call to the signal function results in a SIG_ERR return, the
    value of errno is indeterminate.

The attached patch fixes this by replacing all accessed globals with volatile sig_atomic_t.

This behavior was detected using techniques developed by the SYMBIOSYS research project at COMSYS, RWTH Aachen University. This research is supported by the European Research Council (ERC) under the EU's Horizon 2020 Research and Innovation Programme grant agreement n. 647295 (SYMBIOSYS).

1 Attachments

Discussion


Log in to post a comment.

MongoDB Logo MongoDB