Subject: | Race condition while creating object file |
There is a race condition when an object file is being created than can
cause a process to get a truncated file. The cause is the second
process reading the partially written file before the first process
finishes writing the entire file.
The timeline looks
like:
A: file does not exist
A: open object file to write
A: write first block
B: file exists
B: load object file
A: write rest of file
A: close file
B sees that the file already exists and reads the first half of the
file while A is still writing the rest of the file.