Commit cfbedf17 authored by Niklas Hambüchen's avatar Niklas Hambüchen Committed by Marge Bot

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:

The concrete test case for GHC is at

A previous, nondeterministic reproducer for the issue was provided by
Alexey Kuleshevich in default avatarNiklas Hambüchen <>
Reviewed-by: default avatarAlexey Kuleshevich <>
parent 1f5cc9dc
......@@ -1339,7 +1339,12 @@ runPhase (RealPhase (As with_cpp)) input_fn dflags
liftIO $ debugTraceMsg dflags 4 (text "Running the assembler")
runAssembler input_fn output_fn
-- Atomic write by writing to temp file and then renaming
let temp_output_fn = output_fn <.> "tmp"
runAssembler input_fn temp_output_fn
liftIO $ renameFile temp_output_fn output_fn
return (RealPhase next_phase, output_fn)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment