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

ICE with mutually recursive infinite-sized type and enum from another module #57271

Closed
XavilPergis opened this issue Jan 2, 2019 · 3 comments · Fixed by #65191
Closed

ICE with mutually recursive infinite-sized type and enum from another module #57271

XavilPergis opened this issue Jan 2, 2019 · 3 comments · Fixed by #65191
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@XavilPergis
Copy link

I'm getting a very touchy ICE on rustc 1.33.0-nightly (9eac38634 2018-12-31) running on x86_64-unknown-linux-gnu. I'm not 100% sure what it has to do with...

Here is the minimum example I can trigger the ICE with:

// in `crate::signature` / `src/signature.rs`
use crate::field::BaseType;

pub enum ObjectType {
    Class(ClassTypeSignature),
    Array(TypeSignature),
    TypeVariable(()),
}

pub struct ClassTypeSignature {
    pub package: (),
    pub class: (),
    pub inner: (),
}

pub enum TypeSignature {
    Base(BaseType),
    Object(ObjectType),
}

// in `crate::field` / `src/field.rs`
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
pub enum BaseType {
    Byte,
    Char,
    Double,
    Float,
    Int,
    Long,
    Short,
    Boolean,
}

I'm expecting to see an error about an infinitely-sized type, but instead the compiler crashes. Changes that make the compiler not ICE:

  • Moving field::BaseType into signature
  • Making ObjectType/TypeSignature not mutually recursive
  • Rearranging or removing any field/variant from any of these structs/enums
  • Making ObjectType::Class not contain ClassTypeSignature

Output of RUST_BACKTRACE=1 cargo build: https://gist.github.com/XavilPergis/102774c6c542403db10a351ff013f356
Original code that ICE'd: https://gist.github.com/XavilPergis/dafc2bb478f18cee700f78e16eea81cd

@estebank
Copy link
Contributor

estebank commented Jan 2, 2019

The error is raised here because it is expected that an error should have been emitted before reaching this code branch, presumably by force_from_dep_node:

None => {
if !tcx.sess.has_errors() {
bug!("try_mark_green() - Forcing the DepNode \
should have set its color")
} else {
// If the query we just forced has resulted
// in some kind of compilation error, we
// don't expect that the corresponding
// dep-node color has been updated.
}
}

It seems that the check was added in #49088 to get around similar errors. I wonder if completely removing the check (ignoring the None case and returning None, like in the Red case) would cause any bugs, but looking at the commit that originally introduced this check, we used to return None; always there.

CC @michaelwoerister

@estebank estebank added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 2, 2019
@XavilPergis
Copy link
Author

Here's the code in my repository, by the way: https://github.com/XavilPergis/rvm/blob/ice/class/src/signature.rs

@jonas-schievink jonas-schievink added the C-bug Category: This is a bug. label Aug 6, 2019
@jakubadamw
Copy link
Contributor

@XavilPergis, I tried to compile your ice branch with the 2018-12-31 nightly and it produced the expected errors with no ICEs. Same with the newest nightly and the stable 1.36.

@estebank estebank added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Aug 12, 2019
varkor added a commit to varkor/rust that referenced this issue Oct 7, 2019
tmandry added a commit to tmandry/rust that referenced this issue Oct 11, 2019
…=nikomatsakis

Add some regression tests

- Add a test for rust-lang#62187.
- Clean up the directory structure in `src/test/ui/const-generics`
- Closes rust-lang#64792.
- Closes rust-lang#57399.
- Closes rust-lang#57271.
tmandry added a commit to tmandry/rust that referenced this issue Oct 11, 2019
…=nikomatsakis

Add some regression tests

- Add a test for rust-lang#62187.
- Clean up the directory structure in `src/test/ui/const-generics`
- Closes rust-lang#64792.
- Closes rust-lang#57399.
- Closes rust-lang#57271.
Centril added a commit to Centril/rust that referenced this issue Oct 11, 2019
…=nikomatsakis

Add some regression tests

- Add a test for rust-lang#62187.
- Clean up the directory structure in `src/test/ui/const-generics`
- Closes rust-lang#64792.
- Closes rust-lang#57399.
- Closes rust-lang#57271.
@bors bors closed this as completed in 728adc4 Oct 12, 2019
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. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ 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.

4 participants