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

Interpreter crashes with with stack overflow in rustc #118

Open
stevecheckoway opened this issue Sep 28, 2023 · 2 comments
Open

Interpreter crashes with with stack overflow in rustc #118

stevecheckoway opened this issue Sep 28, 2023 · 2 comments

Comments

@stevecheckoway
Copy link

I'm trying to make an example showing the struct update format similar to https://rust-book.cs.brown.edu/ch05-01-defining-structs.html#creating-instances-from-other-instances-with-struct-update-syntax but rustc is overflowing its stack.

struct Course {
    department: String,
    number: i32,
    section: i32,
    instructor: String,
}

fn new_course(department: &str, number: i32) -> Course {
    Course {
        department: department.to_string(),
        number, // No need to write number: number
        section: 1,
        instructor: String::from("Staff"),
    }
}

fn main() {
    let cs241 = new_course("CSCI", 241);
    let cs241_2 = Course {
        instructor: String::from("Stephen Checkoway"),
        section: 2,
        ..cs241
    };
}

stderr:



thread 'rustc' has overflowed its stack


fatal runtime error: stack overflow


error: could not compile `aquascope_tmp_proj` (bin "aquascope_tmp_proj")

Caused by:
  process didn't exit successfully: `/usr/local/cargo/bin/aquascope-driver /usr/local/rustup/toolchains/nightly-2023-08-25-x86_64-unknown-linux-musl/bin/rustc --crate-name aquascope_tmp_proj --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,metadata -C embed-bitcode=no -C debuginfo=2 -C metadata=eac331abf253eb57 -C extra-filename=-eac331abf253eb57 --out-dir /app/aquascope_tmp_proj/target/plugin-nightly-2023-08-25/debug/deps -C incremental=/app/aquascope_tmp_proj/target/plugin-nightly-2023-08-25/debug/incremental -L dependency=/app/aquascope_tmp_proj/target/plugin-nightly-2023-08-25/debug/deps -C target-feature=-crt-static` (signal: 6, SIGABRT: process abort signal)


@willcrichton
Copy link
Collaborator

willcrichton commented Sep 28, 2023

Hi @stevecheckoway, thanks for the report. You're running into two unimplemented features:

  1. Support for &'static strings (Add support for &'static data to the interpreter #75)
  2. Support for references to unnamed data (Add support for references to unnamed data #119)

(Obviously the stack overflow is not great DX for making you aware of these things ^^)

These are things we intend to implement, time-permitting. For now, you can make your program work by avoiding both limitations if you rewrite:

let cs241 = new_course("CSCI", 241);

To:

let department = String::from("CSCI");
let cs241 = new_course(&department, 241);

This generates a working diagram:

Screen Shot 2023-09-28 at 1 51 10 PM

@stevecheckoway
Copy link
Author

Ah great. Thanks for explaining that this is a known limitation.

And thank you for this great tool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants