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

Crash about overflowing max_stackdepth #5154

Open
tekknolagi opened this issue Jan 24, 2024 · 4 comments
Open

Crash about overflowing max_stackdepth #5154

tekknolagi opened this issue Jan 24, 2024 · 4 comments
Labels
C-bug Something isn't working

Comments

@tekknolagi
Copy link

tekknolagi commented Jan 24, 2024

Summary

I tried to run scrapscript.py with RustPython. It crashed. I reduced the input code with CReduce and then manually from ~4k lines to 21 lines.

Expected

No crash. In the full example, I expect the test suite to run. In the reduced example I expect nothing to happen.

Actual

# scrapscript.py
class LeftParen:
    pass
class RightParen:
    pass
class Lexer:
    def read_char(self) :
        return None
    def read_one(self) :
        while self:
            c = self.read_char()
            break
        else:
            return x
        {
                "(": LeftParen,
                ")": RightParen}
def tokenize():
    lexer = Lexer()
    while (lexer.read_one()) :
        pass
tokenize()
cedar% rustpython scrapscript.py test
[vm/src/frame.rs:1942] self = ExecutingFrame {
    code: code: <code object read_one at ??? file "scrapscript.py", line 8>,
    state: FrameState {
        stack: [
            [PyObject PyStr { value: "(", kind: Ascii, hash: -1 }],
            [PyObject [PyType LeftParen]],
            [PyObject PyStr { value: ")", kind: Ascii, hash: -1 }],
        ],
        blocks: [],
        lasti: 16,
    },
}
thread 'main' panicked at vm/src/frame.rs:1943:9:
tried to push value onto stack but overflowed max_stackdepth
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
cedar%
@youknowone
Copy link
Member

#5273 fixed a max_stackdepth calculation bug.

@tekknolagi
Copy link
Author

Building from main (5d6d1a6) and running still crashes in the same way.

@tekknolagi
Copy link
Author

Reduced further:

# scrapscript.py
def read_one() :
    self = 1
    while self:
        break
    else:
        return self
    {")": 2}
read_one()

@tekknolagi
Copy link
Author

tekknolagi commented May 20, 2024

# scrapscript.py
def f() :
    while 1:
        break
    else:
        return 2
    {1: 2}
f()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants