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

const eval interpreter step limit being hit on nightly for long-running while loop #103814

Closed
pnkfelix opened this issue Oct 31, 2022 · 8 comments · Fixed by #104782
Closed

const eval interpreter step limit being hit on nightly for long-running while loop #103814

pnkfelix opened this issue Oct 31, 2022 · 8 comments · Fixed by #104782
Assignees
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) C-bug Category: This is a bug. P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@pnkfelix
Copy link
Member

pnkfelix commented Oct 31, 2022

I tried this code (playpen):

const _DUMMY: u8 = {
    let mut data = [0; 131072];
    let mut idx = 0;
    while idx < data.len() {
        data[idx] = idx as u8;
        idx += 1;
    }
    5
};

#[test]
fn check() { }

I expected to see this happen: Code compiles, test runs and passes.

Instead, this happened: Code fails to compile, due to:

error[[E0080]](https://doc.rust-lang.org/nightly/error-index.html#E0080): evaluation of constant value failed
 --> src/lib.rs:6:9
  |
6 |         idx += 1;
  |         ^^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`)

For more information about this error, try `rustc --explain E0080`.

It does not occur on stable or beta.

(To be clear: I suspect this might be a const-eval implementation artifact that we cannot readily address. But we may need to figure out how to give better guidance, since the current diagnostic is telling people to muck with an attribute that is not available without opting into a feature gate.)

Meta

rustc --version --verbose:

Nightly channel

Build using the Nightly version: 1.67.0-nightly

(2022-10-30 77e57db384aca99444c3)
@pnkfelix pnkfelix added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. C-bug Category: This is a bug. A-const-eval Area: Constant evaluation (MIR interpretation) labels Oct 31, 2022
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Oct 31, 2022
@pnkfelix pnkfelix changed the title const eval interpreter step limit being hit on nightly const eval interpreter step limit being hit on nightly for long-running while loop Oct 31, 2022
@pnkfelix
Copy link
Member Author

cc #67217

@pnkfelix
Copy link
Member Author

See also discussion in #93481

(if there are other issues filed for this regression, or if there's a precedent for not filing such issues for this particular regression, then my apologies. I searched and couldn't find evidence to not file it.)

@oli-obk oli-obk self-assigned this Oct 31, 2022
celinval added a commit to celinval/kani-dev that referenced this issue Nov 1, 2022
Mitigates model-checking#1822 which is
caused by rust-lang/rust#103814.

Ps.: I also bumped cbmc min version since older versions don't work with
Kani.
@tedinski
Copy link
Contributor

tedinski commented Nov 1, 2022

This apparently affects nightly-2022-10-25 but not nightly-2022-10-24

@celinval
Copy link
Contributor

celinval commented Nov 1, 2022

BTW, we started seeing this issue on nightly-2022-10-25. This test works fine on +nightly-2022-10-24

celinval added a commit to model-checking/kani that referenced this issue Nov 1, 2022
Downgrade the rust toolchain for the nighly before the current version. This mitigates #1822 which is caused by rust-lang/rust#103814.

Ps.: I also bumped cbmc min version since older versions don't work with Kani.
@camshaft
Copy link

camshaft commented Nov 2, 2022

I was able to workaround this issue by replacing data.len() with DATA_LEN

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=4196b2135bd3c14f250f33ec5f160627

@saethlin
Copy link
Member

saethlin commented Nov 7, 2022

I dropped the length of data to 120000 so that this runs on both sides of the regression. Doing the most naive benchmarking I measure a ~11% slowdown in cargo clean && cargo check --tests and a ~16% slowdown in cargo miri test.

How did this get past the compiler perf monitoring? Surely we didn't merge a PR in that time window that regressed one of the secondary benchmarks by 11%, right? Is this some workload that's just very different from ctfe-stress?

@apiraino apiraino added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. I-compiler-nominated Nominated for discussion during a compiler team meeting. labels Nov 9, 2022
@apiraino
Copy link
Contributor

apiraino commented Nov 9, 2022

WG-prioritization assigning priority (Zulip discussion) (also to stimulate a wider T-compiler discussion about it)

@rustbot label -I-prioritize +P-high

@rustbot rustbot added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Nov 9, 2022
@oli-obk oli-obk added regression-from-stable-to-beta Performance or correctness regression from stable to beta. and removed regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels Nov 17, 2022
@apiraino
Copy link
Contributor

visiting during T-compiler meeting on Zulip: followup discussion on this Zulip stream

@rustbot label -I-compiler-nominated

@rustbot rustbot removed the I-compiler-nominated Nominated for discussion during a compiler team meeting. label Nov 18, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 24, 2022
…nkfelix

Bump the const eval step limit

fixes rust-lang#103814

rust-lang#103877 has too much of an impact to beta backport. So let's just increase the limit, avoiding the immediate breakage.

r? `@pnkfelix`
@bors bors closed this as completed in 679f1b7 Nov 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) C-bug Category: This is a bug. P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants