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

bug(parser): infinite loop in tsx #169

Closed
Boshen opened this issue Mar 12, 2023 · 3 comments · Fixed by #242
Closed

bug(parser): infinite loop in tsx #169

Boshen opened this issue Mar 12, 2023 · 3 comments · Fixed by #242
Labels
A-parser Area - Parser C-bug Category - Bug

Comments

@Boshen
Copy link
Member

Boshen commented Mar 12, 2023

This is caught by the fuzzer https://github.com/Boshen/oxc/actions/runs/4395420223/jobs/7697210796

To replicate:

Create a test.tsx with the following string:

1<(V=82<<t-j0<(V=$<LBI<(V=ut<I<(V=$<LBI<(V=uIV=82<<t-j0<(V=$<LBI<(V=ut<I<(V=$<LBI<(V<II>

run cargo run -p oxc_parser --example parser -- test.tsx

and it will run forever.


I'm gussing this is the result of parsing the ambiguous < token, where TypeScript needs to lookahead and rewind forever.

@Boshen Boshen added the C-bug Category - Bug label Mar 12, 2023
@Boshen
Copy link
Member Author

Boshen commented Mar 26, 2023

As a pointer, I suspect ParserState::not_parenthesized_arrow didn't catch a case here.

<( this is the start of parenthesized arrow function, so it kept going and rewinded in an infinite loop.

@Boshen Boshen added the A-parser Area - Parser label Mar 29, 2023
@Boshen
Copy link
Member Author

Boshen commented Apr 1, 2023

I pin pointed to the loop and this try_parse rewind:

https://github.com/Boshen/oxc/blob/b11f774c410a4345a119831a6c9c9dbe216cce35/crates/oxc_parser/src/js/expression.rs#L677-L701

But I got stuck to find a solution ... everything is intertwined together like a hairball 😢

@Boshen
Copy link
Member Author

Boshen commented Apr 1, 2023

I give up, I'll copy TypeScript's source code ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area - Parser C-bug Category - Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant