rust/compiler/rustc_query_system
bors 9e79395f92 Auto merge of #151509 - Zoxc:gen-color-race, r=zetanumbers,petrochenkov
Handle race when coloring nodes concurrently as both green and red

This fixes a race where a duplicate dep node gets written to the dep graph if a node was marked as green and promoted during execution, then marked as red after execution.

This can occur when a `no_hash` query A depends on a query B which cannot be forced so it was not colored when starting execution of query A. During the execution of query A it will execute query B and color it green. Before A finishes another thread tries to mark A green, this time succeeding as B is now green, and A gets promoted and written to metadata. Execution of A then finishes and because it's `no_hash` we assume the result changed and thus we color the node again, now as red and write it to metadata again. This doesn't happen with non-`no_hash` queries as they will be green if all their dependencies are green.

This changes the code coloring nodes red to also use `compare_exchange` to deal with this race ensuring that the coloring of nodes only happens once.

Fixes rust-lang/rust#150018
Fixes rust-lang/rust#142778
Fixes rust-lang/rust#141540
2026-02-10 16:17:00 +00:00
..
src Auto merge of #151509 - Zoxc:gen-color-race, r=zetanumbers,petrochenkov 2026-02-10 16:17:00 +00:00
Cargo.toml Convert to inline diagnostics in rustc_query_system 2026-02-03 14:01:05 +01:00