Skip to content

Stack overflow when opening many blocks #15241

@sholderbach

Description

@sholderbach

Describe the bug

Our parser is sensitive to inputs causing excessive recursion.

E.g. opening but never closing many blocks causes a stack overflow.

How to reproduce

In the REPL (thanks to the syntax highlight parsing pass) or a script open many blocks through {

Image

Expected behavior

While tricky to guard against, for the most likely and egregious cases we may want to consider a recursion limit to fail gracefully in our parser.
And if possible it may be worth rewriting parts of the parsing logic to avoid growing the call stack when given malformed input. (This could be a DoS concern for nuon)

Configuration

key value
version 0.102.1
major 0
minor 102
patch 1
branch main
commit_hash be508cb
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.83.0 (90b35a623 2024-11-26)
rust_channel 1.83.0-x86_64-unknown-linux-gnu
cargo_version cargo 1.83.0 (5ffbef321 2024-10-29)
build_time 2025-02-26 12:08:07 +01:00
build_rust_channel debug
allocator mimalloc
features default, sqlite, trash
installed_plugins formats 0.99.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:parserIssues related to parsingpanicperformanceWork to make nushell quicker and use less resourcesstatus:needs-triageAn issue that hasn't had any proper look

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions