compiler: Write .o files atomically. See #14533
authorNiklas Hambüchen <mail@nh2.me>
Sun, 17 Feb 2019 19:48:45 +0000 (20:48 +0100)
committerMarge Bot <ben+marge-bot@smart-cactus.org>
Fri, 22 Feb 2019 01:58:47 +0000 (20:58 -0500)
commit0e2d300a59b1b5c167d2e7d99a448c8663ba6d7d
tree99a368451db415ee4f0f364ee6ff8e91e306d42f
parent9db92cf0baada362f2b1bd69fbfd156f415d4053
compiler: Write .o files atomically. See #14533

This issue was reproduced with, and the fix confirmed with,
the `hatrace` tool for syscall-based fault injection:

    https://github.com/nh2/hatrace

The concrete test case for GHC is at

    https://github.com/nh2/hatrace/blob/e23d35a2d2c79e8bf49e9e2266b3ff7094267f29/test/HatraceSpec.hs#L185

A previous, nondeterministic reproducer for the issue was provided by
Alexey Kuleshevich in

    https://github.com/lehins/exec-kill-loop

Signed-off-by: Niklas Hambüchen <niklas@fpcomplete.com>
Reviewed-by: Alexey Kuleshevich <alexey@fpcomplete.com>
compiler/main/DriverPipeline.hs