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

Report const eval error inside the query #53821

Merged
merged 21 commits into from
Oct 26, 2018
Merged

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Aug 30, 2018

Functional changes: We no longer warn about bad constants embedded in unused types. This relied on being able to report just a warning, not a hard error on that case, which we cannot do any more now that error reporting is consistently centralized.

r? @RalfJung

fixes #53561

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 30, 2018
@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@@ -71,6 +71,7 @@ pub enum Def {
VariantCtor(DefId, CtorKind), // DefId refers to the enum variant
Method(DefId),
AssociatedConst(DefId),
Closure(hir::BodyId),
Copy link
Member

Choose a reason for hiding this comment

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

I know nothing about HIR. Who could review this part?

LL | const B: i32 = (&A)[1];
| ^^^^^^^^^^^^^^^-------^
| |
| index out of bounds: the len is 0 but the index is 1
Copy link
Member

Choose a reason for hiding this comment

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

Why do we error twice now for the same thing, where we only errored once before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I presume because the query is once called with Reveal::UserFacing and once with Reveal::All

Copy link
Member

Choose a reason for hiding this comment

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

Is it a bug to not use the same Reveal each time? Doesn't this mean the constant is evaluated several times?

@RalfJung
Copy link
Member

The part inside CTFE/miri looks good to me. I do not think I can adequately review the HIR changes though, so I'd prefer if you could get someone else to take a look at that.

There are a huge amount of changes to the ui test output -- some error messages got deduplicated, but many others (and many more, I think) got duplicated. Why is that? Can you avoid that?

@bors

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

Ok(MPlaceTy::from_aligned_ptr(ptr, layout))
if layout.is_unsized() {
assert!(self.tcx.features().unsized_locals, "cannot alloc memory for unsized type");
// allocate a fat pointer slot instead
Copy link
Member

Choose a reason for hiding this comment

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

Wait what? That seems wrong. We can have proper unsized locals, why should we have these indirections? Does that match how the MIR looks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assumed we'd want to mirror rustc codegen

Copy link
Member

Choose a reason for hiding this comment

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

I don't think so. We already have the ability to use an Operand::Indirect with a MemPlace to store the metadata -- that's like a properly typed version of a fat pointer.

LL | bytes: [u8; std::mem::size_of::<Foo>()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which again requires const-evaluating + checking `Foo::bytes::{{constant}}`, completing the cycle
note: cycle used when processing `Foo`
Copy link
Member

Choose a reason for hiding this comment

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

Is it expected that "requires const-evaluating + checking Foo::bytes::{{constant}}" occurs twice at the end of this cycle?

...which requires const-evaluating + checking Foo::bytes::{{constant}}...
...which again requires const-evaluating + checking Foo::bytes::{{constant}}, completing the cycle

@bors

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@bors

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@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 26, 2018
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-distcheck of your PR failed on Travis (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.
[01:14:10] failures:
[01:14:10] 
[01:14:10] ---- [ui (nll)] ui/issues/issue-15919.rs stdout ----
[01:14:10] 
[01:14:10] error: Error: expected failure status (Some(1)) but received status None.
[01:14:10] status: signal: 6
[01:14:10] command: "/checkout/obj/build/tmp/distcheck/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/obj/build/tmp/distcheck/src/test/ui/issues/issue-15919.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/tmp/distcheck/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-15919.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/tmp/distcheck/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/tmp/distcheck/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-15919.nll/auxiliary" "-A" "unused"
[01:14:10] ------------------------------------------
[01:14:10] 
[01:14:10] ------------------------------------------
[01:14:10] stderr:
[01:14:10] stderr:
[01:14:10] ------------------------------------------
[01:14:10] {"message":"the type `[usize; 18446744073709551615]` is too big for the current architecture","code":null,"level":"error","spans":[],"children":[],"rendered":"error: the type `[usize; 18446744073709551615]` is too big for the current architecture\n\n"}
[01:14:10] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[01:14:10] rustc: cxa_atexit.c:100: __new_exitfn: Assertion `l != NULL' failed.
[01:14:10] ------------------------------------------
[01:14:10] 
[01:14:10] thread '[ui (nll)] ui/issues/issue-15919.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3284:9
[01:14:10] note: Run with `RUST_BACKTRACE=1` for a backtrace.
---
[01:14:10] test result: FAILED. 4885 passed; 1 failed; 67 ignored; 0 measured; 0 filtered out
[01:14:10] 
[01:14:10] 
[01:14:10] 
[01:14:10] command did not execute successfully: "/checkout/obj/build/tmp/distcheck/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/tmp/distcheck/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/tmp/distcheck/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/tmp/distcheck/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/obj/build/tmp/distcheck/src/test/ui" "--build-base" "/checkout/obj/build/tmp/distcheck/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/checkout/obj/build/tmp/distcheck/build/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/tmp/distcheck/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--llvm-version" "8.0.0svn\n" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always" "--compare-mode" "nll"
[01:14:10] 
[01:14:10] 
[01:14:10] failed to run: /checkout/obj/build/tmp/distcheck/build/bootstrap/debug/bootstrap test
[01:14:10] Build completed unsuccessfully in 1:02:26
[01:14:10] Build completed unsuccessfully in 1:02:26
[01:14:10] Makefile:58: recipe for target 'check' failed
[01:14:10] make: *** [check] Error 1
[01:14:10] 
[01:14:10] 
[01:14:10] command did not execute successfully: "make" "check"
[01:14:10] 
[01:14:10] 
[01:14:10] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test distcheck
[01:14:10] Build completed unsuccessfully in 1:10:52
---
travis_time:end:24ce8ed2:start=1540546636946475768,finish=1540546636960484251,duration=14008483
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:004c2cf6
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:start:crashlog
obj/cores/core.3138.!checkout!obj!build!tmp!distcheck!build!x86_64-unknown-linux-gnu!stage2!bin!rustc
[New LWP 3146]
[New LWP 3143]
[New LWP 3144]
[New LWP 3138]
[New LWP 3148]
warning: Could not load shared library symbols for 8 libraries, e.g. /lib/x86_64-linux-gnu/libc.so.6.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
Core was generated by `/checkout/obj/build/tmp/distcheck/build/x86_64-unknown-linux-gnu/stage2/bin/rus'.
Program terminated with signal SIGABRT, Aborted.
#0  0x00007fa366e7a428 in ?? ()
#0  0x00007fa366e7a428 in ?? ()
#1  0x00007fa366e7c02a in ?? ()
#2  0x0000000000000020 in ?? ()
#3  0x0000000000000000 in ?? ()
travis_time:end:004c2cf6:start=1540546636968050931,finish=1540546638299764241,duration=1331713310
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:006101dc
travis_time:start:006101dc
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:2484cd71
$ dmesg | grep -i kill

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 @TimNN. (Feature Requests)

@oli-obk
Copy link
Contributor Author

oli-obk commented Oct 26, 2018

I've seen this failure before locally (like before this PR, it's not new). Rerunning the tests makes it go away. It's very frustrating. I'll open a tracking issue for it

@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 26, 2018
@bors
Copy link
Contributor

bors commented Oct 26, 2018

⌛ Testing commit 13d94ee with merge 2f4acffc0719c29ec3e74271ba8cb9db2b0b29ce...

@bors
Copy link
Contributor

bors commented Oct 26, 2018

⌛ Testing commit 13d94ee with merge 10299b2bbc1302c51ae0668d542c7316f62b4382...

@rust-highfive
Copy link
Collaborator

Your PR failed on Travis (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.
Checking out files: 100% (17267/17267), done.
travis_time:end:3b67fa08:start=1540551634958504000,finish=1540551645401632000,duration=10443128000
$ cd rust-lang/rust
$ git checkout -qf 2f4acffc0719c29ec3e74271ba8cb9db2b0b29ce
fatal: reference is not a tree: 2f4acffc0719c29ec3e74271ba8cb9db2b0b29ce
The command "git checkout -qf 2f4acffc0719c29ec3e74271ba8cb9db2b0b29ce" failed and exited with 128 during .
Your build has been stopped.

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 @TimNN. (Feature Requests)

@RalfJung
Copy link
Member

What... was that? It started testing twice?!? Cc @rust-lang/infra

@bors retry

@bors
Copy link
Contributor

bors commented Oct 26, 2018

⌛ Testing commit 13d94ee with merge 694cf75...

bors added a commit that referenced this pull request Oct 26, 2018
Report const eval error inside the query

Functional changes: We no longer warn about bad constants embedded in unused types. This relied on being able to report just a warning, not a hard error on that case, which we cannot do any more now that error reporting is consistently centralized.

r? @RalfJung

fixes #53561
@bors
Copy link
Contributor

bors commented Oct 26, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: RalfJung
Pushing 694cf75 to master...

@nnethercote
Copy link
Contributor

Perf results are mixed. Some big wins for incremental builds (as high as 27%), and some slowdowns of up to 3% for a few benchmarks, mostly keccak and inflate.

@oli-obk
Copy link
Contributor Author

oli-obk commented Oct 27, 2018

We've seen these results before in the PR. attempts to track the regressions down were not very successful. I'll have another look

bors added a commit that referenced this pull request Oct 28, 2018
Delayed CTFE backtraces

This renames the env var that controls CTFE backtraces from `MIRI_BACKTRACE` to `RUST_CTFE_BACKTRACE` so that we can use `MIRI_BACKTRACE` in the miri tool to only show backtraces of the main miri execution.

It also makes `RUST_CTFE_BACKTRACE` only show backtraces that actually get rendered as errors, instead of showing them eagerly when the `Err` happens. The current behavior is near useless in miri because it shows about one gazillion backtraces for errors that we later catch and do not care about. However, @oli-obk likes the current behavior for rustc CTFE work so it is still available via `RUST_CTFE_BACKTRACE=immediate`.

NOTE: This is based on top of #53821. Only [the last three commits](oli-obk/rust@sanity_query...RalfJung:ctfe-backtrace) are new.

Fixes #53355
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Constant validation is not cached