Library callers on small threads can still overflow before MAX_SOURCE_NESTING_DEPTH is reached in debug builds
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Read PR #278’s design discussion and the measurements from #277, then inspect the parser entry points amblicit_syntax::parse_module and amblicit::check, plus crates/amblicit-syntax/tests/parse_nesting.rs and the syntax README requirement SYNTAX-REQ-018. Start by reproducing the debug overflow on a 2 MiB thread; done means the committed test parses parentheses and unary sources to MAX_SOURCE_NESTING_DEPTH - 2 without aborting and the README requirement matches the resulting behavior.
Written by the indexing model from the issue text.
Description
Summary
PR #278 bounds the parser's recursion at MAX_SOURCE_NESTING_DEPTH (256) and makes the amblicit binary run each request on a 64 MiB thread, so the limit holds for the CLI on every platform's default main thread.
The limit bounds recursion, not the thread. Each parser level costs stack according to the build profile (about 4.3 KiB in release, several times that in debug, measured in #277: debug overflowed at 386 parentheses on an 8 MiB main thread). A library caller of amblicit_syntax::parse_module / amblicit::check that parses untrusted sources on a small thread (for example Rust's default 2 MiB spawned thread in a debug build) can therefore still overflow before the parser reaches the limit. The PR's own unit witnesses run on a 64 MiB thread for this reason (crates/amblicit-syntax/tests/parse_nesting.rs, WITNESS_STACK_BYTES).
#277 asked for the library entry point to be safe on smaller thread stacks as well; #278 documents the requirement on the caller (syntax README, SYNTAX-REQ-018) instead of meeting it.
Options
- Reduce the parser's per-level stack cost (smaller frames, fewer nested helper closures on the hot path) so 256 levels fit a 2 MiB thread in debug, and add a witness that parses to the limit on a 2 MiB thread in both profiles.
- Or make the library entry points run the parser on an internally sized thread, as the binary does, accepting a thread spawn per call.
- Or lower the limit, accepting that fewer legitimate sources parse.
Acceptance
- A committed test parses a source at
MAX_SOURCE_NESTING_DEPTH - 2on a 2 MiB thread in a debug build without aborting, for the parentheses and unary shapes at least. - The syntax README's caller requirement is removed or narrowed to match.
Deferred from #278; see its design discussion for the measurements.
- Dominant language
- Rust
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from flyingrobots/edict
-
Update Wasmtime to 48.0.11 for RUSTSEC-2026-0648Possibly taken @flyingrobots claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
flyingrobots/edict#457 ·
-
enhancement type: goalpost
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
flyingrobots/edict#355 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
flyingrobots/edict#306 ·
-
enhancement type: goalpost
Difficulty 4/5 3-5 days Newbie friendliness 42/100
flyingrobots/edict#451 ·
-
enhancement release:target-ir
Difficulty 5/5 Over a week Newbie friendliness 28/100
flyingrobots/edict#450 · 1 comment · 1 reaction ·
All issues in flyingrobots/edict
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
autofixer: follow-up triage: bug triage: classified triage: correctness triage: has-reproducer
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
tursodatabase/turso#13221 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
O-windows relnotes relnotes-needs-review relnotes-tracking-issue T-libs
Difficulty 1/5 Under an hour Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
approved
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
fritzprix/libr-agent#3266 ·
Maintainers usually reply within 1 day