[ccache] ccache interrupt handling bug
tgl at sss.pgh.pa.us
Wed Aug 19 04:17:39 UTC 2015
Joel Rosdahl <joel at rosdahl.net> writes:
> Tom Lane <tgl at sss.pgh.pa.us> 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:
> 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.
Those windows are probably narrow enough to not be an issue in practice,
but it's a bit nervous-making.
One thing that might be worth doing is declaring pid (and hence the
pointer argument) to be volatile so that the compiler wouldn't be tempted
to rearrange the code and maybe make those windows bigger. That's
required for formal C-spec-compliance anyway, given that pid is accessed
by a signal handler.
regards, tom lane
More information about the ccache