Re: ccache interrupt handling bug
Eitan Adler <[email protected]> Tue, 18 Aug 2015 21:33:44 -0700
| Newsgroups | gmane.comp.compilers.ccache |
|---|---|
| Message-ID | <CAF6rxgncK4Nz=F6fzCMz3iGzNsiKnZP0AaE6cV2JfuhUM8XFDw@mail.gmail.com> |
On 18 August 2015 at 21:17, Tom Lane <[email protected]> wrote: > Joel Rosdahl <[email protected]> writes: >> Tom Lane <[email protected]> wrote: >>> Actually, that's a bug not just a cosmetic problem, because it introduces >>> a race condition. > >> Yes, sounds like a race condition that could happen. >> I just pushed this change as a fix: >> https://git.samba.org/?p=ccache.git;a=commitdiff;h=4fdb9580fedac9669508bef0837f46f1e9310e24. >> Opinions on it are welcome. > > Hm. In principle there are still race conditions here: consider what > happens if the SIGINT is received between fork() and storing the PID > into *pid, or after waitpid() and before clearing *pid. FWIW the current signal handler is not fully safe. In particular, it modifies variables which are not volatile sig_atomic_t (see section 7.14.1.2 of the C11 standard for more details). The call to unlink() is safe per POSIX but is not safe according to strict C semantics (see http://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html). Similarly, _Exit is required by C, though _exit is safe per POSIX. -- Eitan Adler