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

typos is hanging on two generated files without any words #1088

Closed
Kijewski opened this issue Aug 30, 2024 · 1 comment · Fixed by #1089
Closed

typos is hanging on two generated files without any words #1088

Kijewski opened this issue Aug 30, 2024 · 1 comment · Fixed by #1089

Comments

@Kijewski
Copy link

Kijewski commented Aug 30, 2024

My guess would be that some sort of exponential backtracking is happening. I guess the program would ultimately finish.

@epage
Copy link
Collaborator

epage commented Aug 30, 2024

Not 100% this is the root cause but it isn't helping...

Our URL and email detection is very rudimentary With comment-depth.txt, we see the whole file as a valid email username, so iterate to the very end and then see no @ at the end and fail. So on nearly every byte we are then looking ahead through the entire file, checking every byte. Twice.

This also means we checking every token type on every byte. We aren't getting any savings from one capturing 10 or 20 bytes.

Capping email usernames and url userinfo's at 1024 characters makes typos take 3s on comment-depth.txt with a debug build.

epage added a commit to epage/typos that referenced this issue Aug 30, 2024
In some test data for rinja, they check some parsing corner cases.
Unfortunately for us, also hit a performance corner case.
The entire file was a valid email username but without an `@`.
This mean for every byte, we checked that every byte after it was a
valid username but then backtracked at the end, repeating this until the
whole file was read.

Fixes crate-ci#1088
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants