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

Hundreads of panics when testing broken files #1145

Open
qarmin opened this issue Mar 31, 2023 · 6 comments
Open

Hundreads of panics when testing broken files #1145

qarmin opened this issue Mar 31, 2023 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@qarmin
Copy link

qarmin commented Mar 31, 2023

When running over hundreads of broken(or even sometimes valid) Javascript/Typescript files, I got multiple crashes

Code Snippet

Example of broken files

{
var x = "1";
/finallyimplements  Cop/yrg
info: String.prototype.replace (searchValue, replaceValue)

Example output:

thread 'main' panicked at 'The specified line index 26 was greater or equal to the number of lines of 26.', /home/rafal/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-swc-ext-0.8.0/src/common/text_info.rs:204:7
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/rules/prefer_const.rs:696:48
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/rules/getter_return.rs:136:8

Pack of broken files(973 files, many will crash with same backtrace - most is less than 1KB is size) - Broken_973.zip

Version

Denolint - c801e44

@qarmin qarmin added the bug Something isn't working label Mar 31, 2023
@qarmin qarmin changed the title Hundreads of panics when testing Hundreads of panics when testing broken files Mar 31, 2023
@magurotuna magurotuna self-assigned this Apr 8, 2023
@magurotuna
Copy link
Member

Thanks for reporting. I'll look into it

@magurotuna
Copy link
Member

@qarmin Could you break the error you got into separate ones? I ran deno_lint on your uploaded files but I only see "unexpected eof" or "unterminated regexp" so far, which I don't think are crashes.
Can you clarify what files trigger crashes?

@qarmin
Copy link
Author

qarmin commented Apr 10, 2023

There is too much files to create issues one by one.

First I compiled dlint with cargo build --release and then run it via dlint run app.js

simplescreenrecorder-2023-04-10_11.12.57.mp4

@magurotuna
Copy link
Member

@qarmin Thanks, I figured out what files are causing the first crash (dprint-swc-ext-0.8.0/src/common/text_info.rs) and the second crash (src/rules/prefer_const.rs). Fixes for these crashes are in #1149 and #1148.
However, I still can't reproduce the third crash, which occurs in src/rules/getter_return.rs. Do you have an idea of which file can cause this crash?

@qarmin
Copy link
Author

qarmin commented Apr 11, 2023

Probably my minimization tool found two crashes inside file(one inside text_info.rs and one getter_return.rs) and minimized this to only one crash related to missing new line.

New pack of broken files - Broken_37.zip.zip

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/rules/getter_return.rs:136:8
thread 'main' panicked at 'internal error: entered unreachable code: Current token is `None`. Parser should not call bump() without knowing current token', /home/rafal/.cargo/registry/src/github.com-1ecc6299db9ec823/swc_ecma_parser-0.130.2/src/parser/input.rs:333:13
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/js_regex/validator.rs:1048:31

Few files probably causes infinite loop(I killed app after 20 seconds of running)

magurotuna added a commit that referenced this issue Apr 12, 2023
This commit prevents dlint from panicking when the input file doesn't contain a final newline character.

Towards #1145
magurotuna added a commit that referenced this issue Apr 12, 2023
This commit prevents panics from happening when scope analysis fails in `prefer-const` rule.

Towards #1145
@qarmin
Copy link
Author

qarmin commented Aug 28, 2023

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/rules/getter_return.rs:136:8
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/rules/getter_return.rs:136:8
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/js_regex/validator.rs:1049:31

Still crashes with latest branch

Broken.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants