)]}'
{
  "commit": "43bcbb623e241e6381149c08e2be653433cc9407",
  "tree": "2196dc18cd3ed1c4aff771c18efd3b28120bdcaf",
  "parents": [
    "cc4036e2ba975066651d138f777b33bb7b50aaee"
  ],
  "author": {
    "name": "ajurkowski",
    "email": "ajurkowski@google.com",
    "time": "Fri Jan 07 15:52:22 2022 -0800"
  },
  "committer": {
    "name": "Copybara-Service",
    "email": "copybara-worker@google.com",
    "time": "Fri Jan 07 15:53:48 2022 -0800"
  },
  "message": "Clear potentially stale state left in `CppCompileAction` from inputs discovery from a previous build.\n\n`CppCompileAction` [stores intermediate state](https://github.com/bazelbuild/bazel/blob/b341802700484d11c775bf02d80f43ba3f33b218/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java#L524) of inputs discovery in the action\nitself to avoid quadratic reevaluation on missing Skyframe dependencies. The\nstate is later [cleared when the execution of the action starts](https://github.com/bazelbuild/bazel/blob/b341802700484d11c775bf02d80f43ba3f33b218/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java#L1425). This\nis principally a problematic approach since we are mutating an analysis time\nobject (action) during execution.\n\nIn particular, if we happen to start discovering inputs, but not execute the compile spawn, the state will be left in the action object. A later build, at a different version, would pick up the stale state and use it as discovered inputs leading to incorrect results (or failures) for such incremental build.\n\nThis is possible e.g. when running a build without `--keep_going` when a failure from another action interrupts the execution after inputs discovery or when the `ActionExecutionFunction` encountered a missing dependency in the middle of discovering inputs (e.g. it did not have [dependent modules available](https://github.com/bazelbuild/bazel/blob/b341802700484d11c775bf02d80f43ba3f33b218/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java#L549-L551)).\n\nAdd a new method to call before the first invocation of `Action::discoverInputs` in each build. Add a boolean flag to detect the first call to `Action::discoverInputs` stored in the Skyframe state used by `ActionExecutionFunction` and use it to clear the potentially stale state.\n\nPiperOrigin-RevId: 420386548\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "5a737cf25caa71d15bba68fb73817dd5b7c58741",
      "old_mode": 33188,
      "old_path": "src/main/java/com/google/devtools/build/lib/actions/Action.java",
      "new_id": "9459f9ac6d5315761ba8d751ba5e05fd11c1d074",
      "new_mode": 33188,
      "new_path": "src/main/java/com/google/devtools/build/lib/actions/Action.java"
    },
    {
      "type": "modify",
      "old_id": "92151ad639109cdc31037f77cf6779e9ff09607f",
      "old_mode": 33188,
      "old_path": "src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java",
      "new_id": "fc377ee54af5147e4fd57429e8b62da5f3dbd198",
      "new_mode": 33188,
      "new_path": "src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java"
    },
    {
      "type": "modify",
      "old_id": "37f78b2d48ac0c5986a44f9544a780a4156d85a8",
      "old_mode": 33188,
      "old_path": "src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java",
      "new_id": "d8bdedc6a92cf54751cedb4b90ce9e866fc5df8a",
      "new_mode": 33188,
      "new_path": "src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java"
    },
    {
      "type": "modify",
      "old_id": "65ee2fa1921485330db0b0b4ff1c8fb0729770fc",
      "old_mode": 33188,
      "old_path": "src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionValue.java",
      "new_id": "d75e6fd66dd74071470d324ea5459cc269fb132c",
      "new_mode": 33188,
      "new_path": "src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionValue.java"
    }
  ]
}
