-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Temporarily bring back Rvalue::Len
#135709
Conversation
Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter cc @rust-lang/miri, @rust-lang/wg-const-eval Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred to the CTFE machinery cc @rust-lang/wg-const-eval Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 This PR changes MIR |
Let me know if y'all would like to brainstorm how to fix this properly, and let's maybe do another crater run before fully removing the operand again. Crater runs should be really quick these days. I think the right solution would be to emit some sort of special copy operation to clone the slice pointer but allow borrowck and miri to understand that we're only copying the ref to read its metadata, similarly to how we have Sorry that the test coverage was lacking; I could not have expected anyone to catch this without a failing test, but thank goodness we have beta backports :) I'll leave this open for a day or so b/c it's the weekend, but I'll likely r+ this soon thereafter. Also open to just backporting this and trying to find a fix-forward on master, though that comes with all the normal complications of that approach that I think we're all aware of. |
No worries from my end about reverting these. Definitely better to get the regression fixed. I can take a couple of simpler smaller steps on the way too, like getting Glad to hear there's a plan to get more tests here! |
☀️ Test successful - checks-actions |
Finished benchmarking commit (c62b732): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowOur benchmarks found a performance regression caused by this PR. Next Steps:
@rustbot label: +perf-regression Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary -2.3%, secondary -1.6%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary -1.1%, secondary 1.7%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeResults (primary 0.0%, secondary 0.3%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 765.901s -> 765.96s (0.01%) |
Revert @rustbot label: +perf-regression-triaged |
Those sound like promising approaches. Adding this info to |
Changes required due to - rust-lang/rust#135344: Less unsafe in `dangling`/`without_provenance` - rust-lang/rust#135661: Stabilize `float_next_up_down` - rust-lang/rust#135709: Temporarily bring back `Rvalue::Len` Resolves: #3840 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
[beta] backports - Always force non-trimming of path in `unreachable_patterns` lint rust-lang#135310 - Add Profile Override for Non-Git Sources rust-lang#135433 - resolve symlinks of LLVM tool binaries before copying them rust-lang#135585 - add cache to `AmbiguityCausesVisitor` rust-lang#135618 - When LLVM's location discriminator value limit is exceeded, emit locations with dummy spans instead of dropping them entirely rust-lang#135643 - Temporarily bring back `Rvalue::Len` rust-lang#135709 - make it possible to use ci-rustc on tarball sources rust-lang#135722 - Remove test panic from File::open rust-lang#135837 - Only assert the `Parser` size on specific arches rust-lang#135855 r? cuviper
[beta] backports - Always force non-trimming of path in `unreachable_patterns` lint rust-lang#135310 - Add Profile Override for Non-Git Sources rust-lang#135433 - resolve symlinks of LLVM tool binaries before copying them rust-lang#135585 - add cache to `AmbiguityCausesVisitor` rust-lang#135618 - When LLVM's location discriminator value limit is exceeded, emit locations with dummy spans instead of dropping them entirely rust-lang#135643 - Temporarily bring back `Rvalue::Len` rust-lang#135709 - make it possible to use ci-rustc on tarball sources rust-lang#135722 - Remove test panic from File::open rust-lang#135837 - Only assert the `Parser` size on specific arches rust-lang#135855 - [beta] TRPL: more backward-compatible Edition changes rust-lang#135843 r? cuviper
Returning this to pending backports because it somehow caused a failure in #136017 (comment). @rustbot label +beta-nominated |
Responding to @lqd from #136017 (comment):
Yes, and only on some targets -- smells like UB or similar codegen trouble...
I tried a complex git bisection between here and beta, cherry-picking this PR at each step and running I'm not sure what to make of that, because it doesn't seem like this should have anything to do with Here's the backtrace I get on the overflow, demangled by
I'm not sure what tail calls have to do with these changes or that test either. |
I admit I was assuming that this was an infinite recursion, but on a whim I actually followed the hint:
This works, and even 9MB is enough for this test. Further, tweaking it down to 4MB also makes the current beta and nightly compilers fail in the same Maybe the |
Can we make rustc's segfault handler detect stack overflows too just like libstd's segfault handler? |
It does, approximately: rust/compiler/rustc_driver_impl/src/signal_handler.rs Lines 98 to 101 in a1d7676
|
This is enough to avoid the --- a/compiler/rustc_mir_build/src/check_tail_calls.rs
+++ b/compiler/rustc_mir_build/src/check_tail_calls.rs
@@ -52,2 +52,3 @@ struct TailCallCkVisitor<'a, 'tcx> {
impl<'tcx> TailCallCkVisitor<'_, 'tcx> {
+ #[cold]
fn check_tail_call(&mut self, call: &Expr<'_>, expr: &Expr<'_>) { ( Would anyone object to me adding that to the beta backport? |
I don't think anyone would, but maybe it can be discussed in tomorrow's t-compiler meeting if you'd like? |
Sure, please do mention it, even if only to raise awareness of the recursion hazard there. I'll wait until after that meeting before I start another backport round anyway, in case there's anything else new. |
Sounds like a missing stacker guard somewhere? rustc is supposed to grow its stacks on-demand. |
The PR that replaced the original ones in this revert also has apparently landed, and maybe that can come into the backport discussion so I’ll mention both tomorrow. cc @apiraino for the agenda |
This was discussed in today's t-compiler meeting:
|
Here's a quick example of the stack overflow with nightly on
So currently nightly only fails if you tighten the stack, but beta with this PR backported will even fail with the default stack. |
(fun fact, the unsafety visitor has the same issue at that min stack size) (edit: couldn't sleep, #136352 should fix the issues and make the backport succeed) |
Add a couple of missing `ensure_sufficient_stacks` r? `@saethlin` I hope you didn't spend time on this already. (I couldn't sleep, opened `check_tail_calls`, there was a single call where it could happen, might as well fix it) This PR adds a couple of missing `ensure_sufficient_stack`s: - one in `check_tail_calls` that prevented the rust-lang#135709 backport on some targets. - after that was fixed, the test still didn't pass starting at 4MB, so I also added one in `check_unsafety` and that made it pass. I didn't add an `rmake` test purposefully limiting the min stack size on `issue-74564-if-expr-stack-overflow.rs`, but we could if we wanted to. On `apple-aarch64-darwin`, this is enough to make `RUST_MIN_STACK=$((1024*1024*3)) ./x test tests/ui --test-args tests/ui/issues/issue-74564-if-expr-stack-overflow.rs` pass for me locally, and it does stack overflow otherwise.
Add a couple of missing `ensure_sufficient_stacks` r? `@saethlin` I hope you didn't spend time on this already. (I couldn't sleep, opened `check_tail_calls`, there was a single call where it could happen, might as well fix it) This PR adds a couple of missing `ensure_sufficient_stack`s: - one in `check_tail_calls` that prevented the rust-lang#135709 backport on some targets. - after that was fixed, the test still didn't pass starting at 4MB, so I also added one in `check_unsafety` and that made it pass. I didn't add an `rmake` test purposefully limiting the min stack size on `issue-74564-if-expr-stack-overflow.rs`, but we could if we wanted to. On `apple-aarch64-darwin`, this is enough to make `RUST_MIN_STACK=$((1024*1024*3)) ./x test tests/ui --test-args tests/ui/issues/issue-74564-if-expr-stack-overflow.rs` pass for me locally, and it does stack overflow otherwise.
(cross-posting for traceability) With #136352 and its accepted beta-backport, we should also be good to go for this backport here. |
[beta] backports - Ensure that we don't try to access fields on a non-struct pattern type rust-lang#135222 - Do not include GCC source code in source tarballs rust-lang#135658 - Temporarily bring back `Rvalue::Len` rust-lang#135709 - Add a couple of missing `ensure_sufficient_stacks` rust-lang#136352 - Enable kernel sanitizers for aarch64-unknown-none-softfloat rust-lang#135905 r? cuviper
r? @compiler-errors as requested in #135671 (comment)
Agreed. To fix the IMO P-critical #135671 for which we somehow didn't have test coverage, this PR temporarily reverts:
usize
#134371Rvalue::Len
🎉 #134330cc @scottmcm
I added the few samples from that issue as a test, but we can add more in the future, in particular it seems @steffahn will work on that.
Fixes #135671. And if we want to land this, it should also be nominated for beta backport.