Skip to content

Race condition when input file is updated while compiling #1497

@egmontkob

Description

@egmontkob

I'm new to Meson+Ninja (ninja 1.8.2 on Ubuntu 18.10). As far as I understand, meson corresponds roughly to autotools and ninja to make. Please tell me if I'm wrong and this bugreport should be filed elsewhere.

This report is the same as the make issue at http://savannah.gnu.org/bugs/?46242 (see http://lists.gnu.org/archive/html/bug-make/2015-10/msg00016.html for followup discussions, developer responses).


There's an inherent race condition in the way ninja handles timestamps. If you save a newer version of a file while ninja is running and is just compiling that input file, the change won't be picked up by subsequent runs of ninja, and you'll be left with an out-of-date binary.

Steps to reproduce:

  1. Have some project.
  2. Open one of the large source files that takes noticeable time to compile.
  3. Edit this file in some valid way (changing the functionality) but do not save it yet.
  4. In a terminal, run ninja to compile your project.
  5. While ninja is running, go back to your editor, but keep your eyes on ninja's output.
  6. When ninja launches that particular gcc (or whatever) that compiles this large file, save the new version.
  7. Go back to the terminal. ninja might have completed by now. If not, you might either – if it has finished processing that file – interrupt it, or wait for it to complete.
  8. Execute ninja again to catch up with the edits you performed. Wait for it to complete.
  9. Launch your app, notice that it does not include your recent changes.

The behavior is obvious from the way ninja checks the timestamps. The source of the file has an earlier timestamp than the compiled object file, since you saved the file before gcc wrote out its output. But these are not corresponding versions.


Please see over there in the make bugreport and mailing list discussion for further thoughts on this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions