Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Zvalidate-mir: Assert that storage is allocated on local use #77369

Merged
merged 3 commits into from
Oct 2, 2020
Merged

-Zvalidate-mir: Assert that storage is allocated on local use #77369

merged 3 commits into from
Oct 2, 2020

Conversation

jonas-schievink
Copy link
Contributor

This extends the MIR validator to check that locals are only used when their backing storage is currently allocated via StorageLive.

The result of this is that miscompilations such as #77359 are caught and turned into ICEs.

The PR currently fails tests because miscompilations such as #77359 are caught and turned into ICEs.

I have confirmed that tests pass (even with -Zvalidate-mir) once SimplifyArmIdentity is turned into a no-op (except mir-opt tests, of course).

@rust-highfive
Copy link
Collaborator

r? @estebank

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 30, 2020
@jonas-schievink
Copy link
Contributor Author

r? @wesleywiser

We now run an extra data flow pass, so this could impact perf.

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Sep 30, 2020

⌛ Trying commit 36365b35ee72d8cfde7949f55517832878a754c0 with merge d952cf6887b310e5009157bddd5894b5f54cb31b...

@jonas-schievink
Copy link
Contributor Author

@bors try-

Bootstrap also fails, because miscompilations such as #77359 are caught and turned into ICEs.

@rust-log-analyzer
Copy link
Collaborator

The job dist-x86_64-linux of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
   Compiling gimli v0.22.0
   Compiling object v0.20.0
   Compiling miniz_oxide v0.4.0
   Compiling hashbrown v0.9.0
error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4691 ~ core[5bc6]::iter::adapters::{impl#95}::size_hint), const_param_did: None }) (end of phase Optimization) at bb0[0]:
use of local _11, which has no storage here
     |
     |
2467 |         if self.n == 0 {
     |
     |
     = note: delayed at compiler/rustc_mir/src/transform/validate.rs:163:36

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:961:13

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.
note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.48.0-nightly (d952cf688 2020-09-30) running on x86_64-unknown-linux-gnu


note: compiler flags: -Z macro-backtrace -Z save-analysis -Z binary-dep-depinfo -Z force-unstable-if-unmarked -C opt-level=3 -C embed-bitcode=no -C codegen-units=1 -C debuginfo=1 -C linker=clang -C link-args=-Wl,-rpath,$ORIGIN/../lib -C prefer-dynamic -C embed-bitcode=yes --crate-type lib
note: some of the compiler flags provided by cargo are hidden

error: could not compile `core`.


To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:2370 ~ object[fa71]::read::traits::Object::symbol_data), const_param_did: None }) (end of phase Optimization) at bb0[0]:
use of local _51, which has no storage here
  --> /cargo/registry/src/github.com-1ecc6299db9ec823/object-0.20.0/src/read/traits.rs:97:9
   |
97 | /         if symbol.is_undefined() {
98 | |             return Ok(None);
   | |_________^
   |
   |
   = note: delayed at compiler/rustc_mir/src/transform/validate.rs:163:36

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:961:13

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.
note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.48.0-nightly (d952cf688 2020-09-30) running on x86_64-unknown-linux-gnu


note: compiler flags: -Z macro-backtrace -Z save-analysis -Z binary-dep-depinfo -Z force-unstable-if-unmarked -C opt-level=3 -C embed-bitcode=no -C codegen-units=1 -C debuginfo=0 -C linker=clang -C link-args=-Wl,-rpath,$ORIGIN/../lib -C prefer-dynamic -C embed-bitcode=yes --crate-type lib
note: some of the compiler flags provided by cargo are hidden

error: build failed
error: build failed
command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "16" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace profiler compiler-builtins-c" "--manifest-path" "/checkout/library/test/Cargo.toml" "--message-format" "json-render-diagnostics"
failed to run: /checkout/obj/build/bootstrap/debug/bootstrap dist --host x86_64-unknown-linux-gnu --target x86_64-unknown-linux-gnu
Build completed unsuccessfully in 0:14:56
== clock drift check ==
  local time: Wed Sep 30 17:20:46 UTC 2020
  local time: Wed Sep 30 17:20:46 UTC 2020
  network time: Wed, 30 Sep 2020 17:20:46 GMT
== end clock drift check ==
##[error]Process completed with exit code 1.
Terminate orphan process: pid (6062) (python)

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @rust-lang/infra. (Feature Requests)

@jonas-schievink
Copy link
Contributor Author

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 30, 2020
@jonas-schievink
Copy link
Contributor Author

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 30, 2020
@jonas-schievink jonas-schievink changed the title validate: storage must be allocated on local use -Zvalidate-mir: Assert that storage is allocated on local use Sep 30, 2020
@wesleywiser
Copy link
Member

@bors try

@bors
Copy link
Contributor

bors commented Oct 1, 2020

⌛ Trying commit 36365b35ee72d8cfde7949f55517832878a754c0 with merge 1bdd5353b898fca7dc1cc8e53331d72c296eea8a...

@jonas-schievink
Copy link
Contributor Author

This needs #77396 before bootstrapping will work

@rust-log-analyzer
Copy link
Collaborator

The job dist-x86_64-linux of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
   Compiling gimli v0.22.0
   Compiling object v0.20.0
   Compiling miniz_oxide v0.4.0
   Compiling hashbrown v0.9.0
error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4693 ~ core[5bc6]::iter::adapters::{impl#95}::size_hint), const_param_did: None }) (end of phase Optimization) at bb0[0]:
use of local _11, which has no storage here
     |
     |
2477 |         if self.n == 0 {
     |
     |
     = note: delayed at compiler/rustc_mir/src/transform/validate.rs:163:36

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:961:13

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.
note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.48.0-nightly (1bdd5353b 2020-10-01) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z macro-backtrace -Z save-analysis -Z binary-dep-depinfo -Z force-unstable-if-unmarked -C opt-level=3 -C embed-bitcode=no -C codegen-units=1 -C debuginfo=1 -C linker=clang -C link-args=-Wl,-rpath,$ORIGIN/../lib -C prefer-dynamic -C embed-bitcode=yes --crate-type lib
note: some of the compiler flags provided by cargo are hidden

error: could not compile `core`.


To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:2370 ~ object[fa71]::read::traits::Object::symbol_data), const_param_did: None }) (end of phase Optimization) at bb0[0]:
use of local _51, which has no storage here
  --> /cargo/registry/src/github.com-1ecc6299db9ec823/object-0.20.0/src/read/traits.rs:97:9
   |
97 | /         if symbol.is_undefined() {
98 | |             return Ok(None);
   | |_________^
   |
   |
   = note: delayed at compiler/rustc_mir/src/transform/validate.rs:163:36

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:961:13

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.
note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.48.0-nightly (1bdd5353b 2020-10-01) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z macro-backtrace -Z save-analysis -Z binary-dep-depinfo -Z force-unstable-if-unmarked -C opt-level=3 -C embed-bitcode=no -C codegen-units=1 -C debuginfo=0 -C linker=clang -C link-args=-Wl,-rpath,$ORIGIN/../lib -C prefer-dynamic -C embed-bitcode=yes --crate-type lib
note: some of the compiler flags provided by cargo are hidden

error: build failed
error: build failed
command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "16" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace profiler compiler-builtins-c" "--manifest-path" "/checkout/library/test/Cargo.toml" "--message-format" "json-render-diagnostics"
failed to run: /checkout/obj/build/bootstrap/debug/bootstrap dist --host x86_64-unknown-linux-gnu --target x86_64-unknown-linux-gnu
Build completed unsuccessfully in 0:14:52
== clock drift check ==
  local time: Thu Oct  1 14:38:18 UTC 2020
  local time: Thu Oct  1 14:38:18 UTC 2020
  network time: Thu, 01 Oct 2020 14:38:18 GMT
== end clock drift check ==
##[error]Process completed with exit code 1.
Terminate orphan process: pid (5347) (python)

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @rust-lang/infra. (Feature Requests)

@bors
Copy link
Contributor

bors commented Oct 1, 2020

💔 Test failed - checks-actions

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 1, 2020
@jonas-schievink
Copy link
Contributor Author

Pushed a temp. commit that disables the pass to get perf data

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Oct 1, 2020

⌛ Trying commit e32bb31b958b87a677515ca5881169f88a20aca6 with merge 6c70b42c961226e0059a4aa0bef7f315aad8ad8c...

@bors
Copy link
Contributor

bors commented Oct 2, 2020

☀️ Try build successful - checks-actions, checks-azure
Build commit: 6c70b42c961226e0059a4aa0bef7f315aad8ad8c (6c70b42c961226e0059a4aa0bef7f315aad8ad8c)

@rust-timer
Copy link
Collaborator

Queued 6c70b42c961226e0059a4aa0bef7f315aad8ad8c with parent 8fe73e8, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (6c70b42c961226e0059a4aa0bef7f315aad8ad8c): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never

Copy link
Member

@wesleywiser wesleywiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great and #77396 just merged so you should be able to bootstrap now.

@jonas-schievink
Copy link
Contributor Author

@bors r=wesleywiser

@bors
Copy link
Contributor

bors commented Oct 2, 2020

📌 Commit c47011f has been approved by wesleywiser

@bors bors removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 2, 2020
@bors
Copy link
Contributor

bors commented Oct 2, 2020

⌛ Testing commit c47011f with merge c7ec262b251125405b06f5b4f71a143146f54a93...

@bors
Copy link
Contributor

bors commented Oct 2, 2020

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 2, 2020
@jonas-schievink
Copy link
Contributor Author

= note: LINK : fatal error LNK1102: out of memory

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 2, 2020
@bors
Copy link
Contributor

bors commented Oct 2, 2020

⌛ Testing commit c47011f with merge be38081...

@bors
Copy link
Contributor

bors commented Oct 2, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: wesleywiser
Pushing be38081 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 2, 2020
@bors bors merged commit be38081 into rust-lang:master Oct 2, 2020
@rustbot rustbot added this to the 1.48.0 milestone Oct 2, 2020
@jonas-schievink jonas-schievink deleted the validate-storage-liveness branch October 3, 2020 20:47
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 20, 2020
…cation, r=wesleywiser

Disable MatchBranchSimplification

This optimization can result in unsoundness, because it introduces
additional uses of a place holding the discriminant value without
ensuring that it is valid to do so.

Found by validation from rust-lang#77369 / rust-lang#78147.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants