Skip to content

miri fails to apply recursion limit, hits stack overflow instead #2934

Open

Description

tests/ui/issues/issue-37311-type-length-limit/issue-37311.rs

// build-fail
// normalize-stderr-test: ".nll/" -> "/"
// ignore-compare-mode-next-solver (hangs)

trait Mirror {
    type Image;
}

impl<T> Mirror for T { type Image = T; }

trait Foo {
    fn recurse(&self);
}

impl<T> Foo for T {
    #[allow(unconditional_recursion)]
    fn recurse(&self) {
        (self, self).recurse(); //~ ERROR reached the recursion limit
    }
}

fn main() {
    ().recurse();
}

cargo check or build:

error: reached the recursion limit while instantiating `<(&(&(..., ...), ...), ...) as Foo>::recurse`
  --> src/main.rs:18:9
   |
18 |         (self, self).recurse(); //~ ERROR reached the recursion limit
   |         ^^^^^^^^^^^^^^^^^^^^^^
   |
note: `<T as Foo>::recurse` defined here
  --> src/main.rs:17:5
   |
17 |     fn recurse(&self) {
   |     ^^^^^^^^^^^^^^^^^
   = note: the full type name has been written to '/tmp/im/mri/target/release/deps/mri-6a905e68387b7bf1.long-type.txt'

error: could not compile `mri` (bin "mri") due to previous error

Yet cargo miri run accepts this code and will stack overflow eventually 🤔

thread 'rustc' has overflowed its stack
fatal runtime error: stack overflow
[1]    378748 IOT instruction  cargo --color=always miri run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-interpreterArea: affects the core interpreterC-bugCategory: This is a bug.I-ICEImpact: makes Miri crash with some ICE

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions