your-diary / piet_programming_language

Interpreter for Piet Programming Language
MIT License
7 stars 3 forks source link

Stack overflow #1

Closed JanEricNitschke closed 1 month ago

JanEricNitschke commented 1 month ago

Hi, i just came across this interpreter, but i am getting stack overflow.

Specifically

$ piet_programming_language FullGame.png

thread 'main' has overflowed its stack

For this input: FullGame

your-diary commented 1 month ago

Thank you for the report.

It seems DFS eats up the entire stack because your input is very large.

I'll release the fixed version as soon as possible, but if you are in a hurry, please replace src/main.rs with this:

use std::error::Error;

use clap::Parser;

use piet_programming_language::args::Args;

fn main() -> () {
    let stack_size = 100 * 1024 * 1024; //default =~ 8 * 1024 * 1024

    let main = move || {
        let args = Args::parse();
        println!("{:?}", piet_programming_language::run(&args));
    };

    let child = std::thread::Builder::new()
        .stack_size(stack_size)
        .spawn(main)
        .unwrap();

    child.join().unwrap();
}
your-diary commented 1 month ago

Fixed in db96fda.

JanEricNitschke commented 1 month ago

Thanks for the quick fix! I now swapped to your version for my CI.

If you want feel free to use the image for tests. (But use this version as the one i posted here was bugged)

Also as a note, when installing i get a bunch of clippy warnings, mostly around unnecessary parentheses.


 `piet_programming_language` (lib) generated 67 warnings (run `cargo fix --lib -p piet_programming_language` to apply 67 suggestions
)```
your-diary commented 1 month ago

@JanEricNitschke

If you want feel free to use the image for tests. (But use this version as the one i posted here was bugged)

Thank you. Added your work to the integration tests with input1 and input2. The tests will be included in the next release (in a few days by the way).

Also as a note, when installing i get a bunch of clippy warnings, mostly around unnecessary parentheses.

This will also be fixed in the next release.