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

Octal literal larger than 2^58 - 1 causes Deno to hang indefinitely #10954

Closed
metanomial opened this issue Jun 14, 2021 · 3 comments · Fixed by denoland/deno_lint#732, denoland/deno_doc#106 or #10959

Comments

@metanomial
Copy link

Running:

017777777777777777777;

throws SyntaxError: Octal literals are not allowed in strict mode.

Running:

020000000000000000000;

hangs indefinitely.

@metanomial
Copy link
Author

This bug also causes Deno lint to hang, and therefore causes the Deno VSCode extension to hang.

I encountered this bug after pasting a series of long binary numbers into a page and formatting (format on save was enabled) the document before adding the 0b prefixes. The binary numbers starting with 0 bits were valid octal literals well over 2^58. A window reload was required to unblock the formatter.

@magurotuna
Copy link
Member

This apparently is caused by the same cause as #10893.

Running dlint run foo.ts, where dlint is brought from deno_lint repo and foo.ts contains 020000000000000000000;, I got:

thread 'main' panicked at 'attempt to multiply with overflow', /Users/yusuktan/.cargo/registry/src/github.com-1ecc6299db9ec823/swc_ecma_parser-0.57.1/src/lexer/number.rs:405:24
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This error is identical to the one reported in #10893.
While we'd need to wait for swc to be fixed, chances are that we could fix the issue of hang ourselves.

@magurotuna
Copy link
Member

After some investigation, the hang happens only in release build, not in debug build because in debug build Rust checks for overflow on every arithmetic operation.
Also, in the release build, the hang is caused by an infinite loop that occurs unexpectedly due to overflow, so it seems like there's nothing we can do to address it ourselves. All we can do is wait for the upstream (swc) fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants