diff options
| author | bors <bors@rust-lang.org> | 2021-03-13 17:52:22 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-03-13 17:52:22 +0000 |
| commit | e7e1dc158c3de232750b568163f6941a184ee8be (patch) | |
| tree | fcd85724f118e2c774ba10948cb039bde64011ac /compiler/rustc_query_system/src/query | |
| parent | 56f74c52c1bb627ada01992787116054bf1e66e9 (diff) | |
| parent | 7d7c81a114eac8054d9e7e1d238ad05b116f12f1 (diff) | |
| download | rust-e7e1dc158c3de232750b568163f6941a184ee8be.tar.gz rust-e7e1dc158c3de232750b568163f6941a184ee8be.zip | |
Auto merge of #83007 - Aaron1011:incr-verify-default, r=Mark-Simulacrum
Turn `-Z incremental-verify-ich` on by default Issue #82920 showed that the kind of bugs caught by this flag have soundness implications.
Diffstat (limited to 'compiler/rustc_query_system/src/query')
| -rw-r--r-- | compiler/rustc_query_system/src/query/plumbing.rs | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index c3e92b87c27..6e16f803f8c 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -533,7 +533,13 @@ where None }; - let result = if let Some(result) = result { + if let Some(result) = result { + // If `-Zincremental-verify-ich` is specified, re-hash results from + // the cache and make sure that they have the expected fingerprint. + if unlikely!(tcx.dep_context().sess().opts.debugging_opts.incremental_verify_ich) { + incremental_verify_ich(*tcx.dep_context(), &result, dep_node, dep_node_index, query); + } + result } else { // We could not load a result from the on-disk cache, so @@ -545,20 +551,21 @@ where prof_timer.finish_with_query_invocation_id(dep_node_index.into()); - result - }; - - // If `-Zincremental-verify-ich` is specified, re-hash results from - // the cache and make sure that they have the expected fingerprint. - if unlikely!(tcx.dep_context().sess().opts.debugging_opts.incremental_verify_ich) { + // Verify that re-running the query produced a result with the expected hash + // This catches bugs in query implementations, turning them into ICEs. + // For example, a query might sort its result by `DefId` - since `DefId`s are + // not stable across compilation sessions, the result could get up getting sorted + // in a different order when the query is re-run, even though all of the inputs + // (e.g. `DefPathHash` values) were green. + // + // See issue #82920 for an example of a miscompilation that would get turned into + // an ICE by this check incremental_verify_ich(*tcx.dep_context(), &result, dep_node, dep_node_index, query); - } - result + result + } } -#[inline(never)] -#[cold] fn incremental_verify_ich<CTX, K, V: Debug>( tcx: CTX::DepContext, result: &V, |
