RustPython / Parser

MIT License
73 stars 28 forks source link

Stack overflow when parsing pandas.io.formats.xml #106

Closed notdanilo closed 11 months ago

notdanilo commented 11 months ago

I've been investigating it, but the problem is deep down in the generated python parser (parser/src/python.rs) thread 'main' has overflowed its stack while parsing https://github.com/pandas-dev/pandas/blob/main/pandas/io/formats/xml.py

Parsing code:

let input = std::fs::read_to_string(xml_py_path).unwrap();
parse(input, Mode::Module, "<embedded>")
notdanilo commented 11 months ago

Same happening with https://github.com/pytorch/pytorch/blob/main/torch/distributed/rendezvous.py

This is becoming a major blocker for my project and I am willing to collaborate with the solution

youknowone commented 11 months ago

Thank you for reporting! Could you also share the error messages when RUST_BACKTRACE=1 is given?

notdanilo commented 11 months ago

It isn't showing much

RUST_BACKTRACE=1 cargo run -p ligen-editor
    Finished dev [unoptimized + debuginfo] target(s) in 0.12s
     Running `target\debug\ligen-editor.exe --debug`

thread 'main' has overflowed its stack
error: process didn't exit successfully: `target\debug\ligen-editor.exe --debug` (exit code: 0xc000041d)
notdanilo commented 11 months ago

Let me debug it a little more.

It seems like this is working:

use rustpython_parser_core::Mode;

#[test]
fn xml() {
    let source = include_str!("xml.py");
    let source = rustpython_parser::parse(source, Mode::Module, "<embedded>")
        .expect("Failed to parse xml.py");
    println!("{:?}", source);
}

Maybe the problem is on my side. I will report it back ASAP.

notdanilo commented 11 months ago

My application loader is taking half of the stack. I am using stacker::grow as a quick solution. I am closing this issue since it isn't related to rustpython_parser.