Skip to content

Parser time and memory use grows exponentially on sequence of [[[[ #10438

@anka-213

Description

@anka-213

Describe the bug

When you type a sequence of open square braces, the parser branches exponentially and uses exponentially more memory for each extra branch.

How to reproduce

  1. Type [[[[[[[[[[[[[[[[[[[[[[[[ in nushell
  2. Watch as every keystroke gets slower and the memory use of nu will soon be in the gigabytes

Expected behavior

At least be polynomial in parsing time

Screenshots

No response

Configuration

version | transpose key value | to md --pretty

key value
version 0.83.1
branch
commit_hash
build_os macos-x86_64
build_target x86_64-apple-darwin
rust_version rustc 1.71.1 (eb26296b5 2023-08-03) (built from a source tarball)
cargo_version cargo 1.71.1
build_time 1980-01-01 00:00:00 +00:00
build_rust_channel release
allocator standard
features default, sqlite, trash, which, zip
installed_plugins hist, plot, xyplot

Additional context

Found using the fuzzer. Original comment here #10376 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceWork to make nushell quicker and use less resources

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions