oxc-project / oxc-project/backlog
Recursing binary expression causes stackoverflow
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 7
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
When oxc is being used in Rolldown run on large applications (lots of javascript code), the combination of tokio + rayon + recursing binary expressions in transform and codegen can easily cause stack overflow.
This was evident when I worked on Rspack with swc. The proposed solution was to set RUST_MIN_STACK to a super high value.
Hours can be lost when debugging such cases, and I don't want to tell my downstream users to set a higher RUST_MIN_STACK.
Besides, esbuild unrolls its recursions for binary expressions, and we should do the same since our goal is to target super large codebases.
To trigger the stack overflow, we can have a set of tests where RUST_MIN_STACK is to a lower number.
tasks/coverage/misc/pass/swc-1627.js also contains a large binary expression.
Or we can dynamically generate a large dynamic expression so we don't commit in a huge file.
Seen in wild: https://github.com/denoland/deno/issues/24325#issuecomment-2203867362
"AAEAAAASAQAABAAgR0RFRrRCsIIAAir4AAACYkdQT1Or8IZpAAItXAAAZS5H" +
"U1VCeoGFdwACkowAABWQT1MvMpl2sYAAAhh4AAAAYGNtYXDG7lFtAAId8AAA" +
"BoJjdnQgBg4uPQACJ2gAAABaZnBnbYP7I6sAAiR0AAABvGdhc3AACAATAAIq" +
"7AAAAAxnbHlm1d+kywAAASwAAfh4aGRteHmPiKEAAhjYAAAFGGhlYWT9R9JX" +
"AAID5AAAADZoaGVhDUgS1wACGFQAAAAkaG10eN7XI9kAAgQcAAAUOGxvY2HG" +
// <continues for ~3864 more lines
And code generated file: https://github.com/StoneCypher/jssm/blob/main/src/ts/fsl_parser.ts
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start by reproducing the overflow with a low RUST_MIN_STACK using tasks/coverage/misc/pass/swc-1627.js or a generated large dynamic expression. Inspect the transform and codegen handling of binary expressions, then verify that large expressions no longer overflow and add a regression test covering the low-stack case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100