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

endless loop by running cargo test with toolchain 2024-05-14 #125269

Closed
xMAC94x opened this issue May 19, 2024 · 4 comments · Fixed by #125343
Closed

endless loop by running cargo test with toolchain 2024-05-14 #125269

xMAC94x opened this issue May 19, 2024 · 4 comments · Fixed by #125343
Assignees
Labels
C-bug Category: This is a bug. I-compiletime Issue: Problems and improvements with respect to compile times. L-non_local_definitions Lint: non_local_definitions P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Comments

@xMAC94x
Copy link

xMAC94x commented May 19, 2024

I tried this code:

(sorry, i couldn't extract a minimal example and reproduce it)

git clone https://gitlab.com/veloren/veloren
cd veloren
git checkout e48fc4c2b235ceab3c1a551292c45c46d47e7130
cd common
cargo test

I expected to see this happen: ElimCase doctest in line 86 to finish after some time

Instead, this happened: the tests takes endless (i waited 2 hours in CI)

Meta

rustc --version --verbose:

rustc 1.80.0-nightly (ab14f944a 2024-05-13)
binary: rustc
commit-hash: ab14f944afe4234db378ced3801e637eae6c0f30
commit-date: 2024-05-13
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.4

cargo test:

   Doc-tests veloren_common

running 14 tests
test common/src/terrain/block.rs - terrain::block::Block (line 120) ... ignored
...
test common/src/typed.rs - typed::ElimCase (line 107) ... ok
...
test common/src/typed.rs - typed::ElimCase (line 86) has been running for over 60 seconds

code in the doc-test in question:

/// ```
/// veloren_common::make_case_elim!(
///     my_type_module,
///     #[repr(u32)]
///     #[derive(Clone,Copy)]
///     pub enum MyType {
///         Constr1 = 0,
///         #[typed(pure)] Constr2(arg : u8) = 1,
///         /* ..., */
///     }
/// );
/// ```

Workaround

As workaround we added a main function to the doctest, as the test doesnt execute code so far (only defines stuff) it then runs immediately again
https://gitlab.com/veloren/veloren/-/commit/3cc4b947ebd049dcdf82ca4a66a815d32d4d43f8

@xMAC94x xMAC94x added the C-bug Category: This is a bug. label May 19, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 19, 2024
@lukas-code
Copy link
Member

lukas-code commented May 19, 2024

This regressed in #123594, where the new solver got enabled for the non_local_definitions lint.

It looks like the core issue here is some kind of exponential runtime in the new solver when there are many bounds on associated types.

Also, this is unrelated to rustdoc and can be reproduced with just rustc.

"minimal" repro
pub trait Typed {}

pub struct SpeciesCases<Elim>(Elim);

pub trait SpeciesPackedElim {
    type Ogre;
    type Cyclops;
    type Wendigo;
    type Cavetroll;
    type Mountaintroll;
    type Swamptroll;
    type Dullahan;
    type Werewolf;
    type Occultsaurok;
    type Mightysaurok;
    type Slysaurok;
    type Mindflayer;
    type Minotaur;
    type Tidalwarrior;
    type Yeti;
    type Harvester;
    type Blueoni;
    type Redoni;
    type Cultistwarlord;
    type Cultistwarlock;
    type Huskbrute;
    type Tursus;
    type Gigasfrost;
    type AdletElder;
    type SeaBishop;
    type HaniwaGeneral;
    type TerracottaBesieger;
    type TerracottaDemolisher;
    type TerracottaPunisher;
    type TerracottaPursuer;
    type Cursekeeper;
}

impl<'b, Elim: SpeciesPackedElim> Typed for &'b SpeciesCases<Elim>
where
    &'b Elim::Ogre: Typed,
    &'b Elim::Cyclops: Typed,
    &'b Elim::Wendigo: Typed,
    &'b Elim::Cavetroll: Typed,
    &'b Elim::Mountaintroll: Typed,
    &'b Elim::Swamptroll: Typed,
    &'b Elim::Dullahan: Typed,
    &'b Elim::Werewolf: Typed,
    &'b Elim::Occultsaurok: Typed,
    &'b Elim::Mightysaurok: Typed,
    &'b Elim::Slysaurok: Typed,
    &'b Elim::Mindflayer: Typed,
    &'b Elim::Minotaur: Typed,
    &'b Elim::Tidalwarrior: Typed,
    &'b Elim::Yeti: Typed,
    &'b Elim::Harvester: Typed,
    &'b Elim::Blueoni: Typed,
    &'b Elim::Redoni: Typed,
    &'b Elim::Cultistwarlord: Typed,
    &'b Elim::Cultistwarlock: Typed,
    &'b Elim::Huskbrute: Typed,
    &'b Elim::Tursus: Typed,
    &'b Elim::Gigasfrost: Typed,
    &'b Elim::AdletElder: Typed,
    &'b Elim::SeaBishop: Typed,
    &'b Elim::HaniwaGeneral: Typed,
    &'b Elim::TerracottaBesieger: Typed,
    &'b Elim::TerracottaDemolisher: Typed,
    &'b Elim::TerracottaPunisher: Typed,
    &'b Elim::TerracottaPursuer: Typed,
    &'b Elim::Cursekeeper: Typed,
{}

fn main() {
    pub struct Cases;
    impl<'b> Typed for &'b Cases {}
}

@rustbot rustbot added I-compiletime Issue: Problems and improvements with respect to compile times. L-non_local_definitions Lint: non_local_definitions regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) I-prioritize Issue: Indicates that prioritization has been requested for this issue. regression-from-stable-to-beta Performance or correctness regression from stable to beta. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels May 19, 2024
@lqd
Copy link
Member

lqd commented May 20, 2024

cc @lcnr could the couple search graph PRs helping on fuchsia also help here?

@lcnr lcnr changed the title [rustdoc] endless loop by running cargo test with toolchain 2024-05-14 endless loop by running cargo test with toolchain 2024-05-14 May 20, 2024
@lcnr
Copy link
Contributor

lcnr commented May 20, 2024

looking into it, thanks @lukas-code for the minimization.

@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@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 May 21, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue May 28, 2024
…, r=compiler-errors

`-Znext-solver`: eagerly normalize when adding goals

fixes rust-lang#125269. I am not totally with this fix and going to keep this open until we have a more general discussion about how to handle hangs caused by lazy norm in the new solver.
workingjubilee added a commit to workingjubilee/rustc that referenced this issue May 28, 2024
…, r=compiler-errors

`-Znext-solver`: eagerly normalize when adding goals

fixes rust-lang#125269. I am not totally with this fix and going to keep this open until we have a more general discussion about how to handle hangs caused by lazy norm in the new solver.
@bors bors closed this as completed in fb95fda May 28, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 28, 2024
Rollup merge of rust-lang#125343 - lcnr:eagerly-normalize-added-goals, r=compiler-errors

`-Znext-solver`: eagerly normalize when adding goals

fixes rust-lang#125269. I am not totally with this fix and going to keep this open until we have a more general discussion about how to handle hangs caused by lazy norm in the new solver.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-compiletime Issue: Problems and improvements with respect to compile times. L-non_local_definitions Lint: non_local_definitions P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants