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

Panic in oxc-miette, when linting file bigger that 64KB #9738

Closed
qarmin opened this issue Mar 13, 2025 · 8 comments · Fixed by #9888
Closed

Panic in oxc-miette, when linting file bigger that 64KB #9738

qarmin opened this issue Mar 13, 2025 · 8 comments · Fixed by #9888
Assignees

Comments

@qarmin
Copy link

qarmin commented Mar 13, 2025

File content(at the bottom should be attached raw, not formatted file - github removes some non-printable characters, so copying from here may not work):

(Truncated, because real file have size 64KB)

(()=>{var e={6544:(e,r,t)=>{"use strict";var a=t(9562);e.exports=defineKeywords;function defineKeywords(e,r){if(Array.isArray(r)){for(var t=0;t<r.length;t++)get(r[t])(e);return e}if(r){get(r)(e);return e}for(r in a)get(r)(e);return e}defineKeywords.get=get;function get(e){var r=a[e];if(!r)throw new Error("Unknown keyword "+e);return r}},3314:(e,r,t)=>{"use strict";var a=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d:\d\d)?$/i;var s=/t|\s/i;var i={date:compareDate,time:compareTime,"date-time":compareDateTime};var o={type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:false};e.exports=function(e){var r="format"+e;return function defFunc(a){defFunc.definition={type:"string",inline:t(6549),statements:true,errors:"full",dependencies:["format"],metaSchema:{anyOf:[{type:"string"},o]}};a.addKeyword(r,defFunc.definition);a.addKeyword("formatExclusive"+e,{dependencies:["format"+e],metaSchema:{anyOf:[{type:"boolean"},o]}});extendFormats(a);return a}};function extendFormats(e){var r=e._formats;for(var t in i){var a=r[t];if(typeof a!="object"||a instanceof RegExp||!a.validate)a=r[t]={validate:a};if(!a.compare)a.compare=i[t]}}function compareDate(e,r){if(!(e&&r))return;if(e>r)return 1;if(e<r)return-1;if(e===r)return 0}function compareTime(e,r){if(!(e&&r))return;e=e.match(a);r=r.match(a);if(!(e&&r))return;e=e[1]+e[2]+e[3]+(e[4]||"");r=r[1]+r[2]+r[3]+(r[4]||"");if(e>r)return 1;if(e<r)return-1;if(e===r)return 0}function compareDateTime(e,r){if(!(e&&

...

message: 'should match some schema in anyOf' "}if(e.opts.verbose){a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+f+" "}a+=" } "}else{a+=" {} "}a+=";  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";if(!e.compositeRule&&u){if(e.async){a+=" throw new ValidationError(vErrors); "}else{a+=" validate.errors = vErrors; return false; "}}a+=" } else {  errors = "+h+"; if (vErrors !== null) { if ("+h+") vErrors.length = "+h+"; else vErrors = null; } ";if(e.opts.allErrors){a+=" } "}}else{if(u){a+=" if (true) { "}}return a}},9263:e=>{"use strict";e.exports=function generate_comment(e,r,t){var a=" ";var s=e.schema[r];var i=e.errSchemaPath+"/"+r;var o=!e.opts.allErrors;var n=e.util.totedString(s);if(e.opts.$comment===true){a+=" console.log("+n+");"}else if(typeof e.optsl;

command

timeout -v 150 oxlint -D all -D nursery --import-plugin --jsdoc-plugin --jest-plugin --vitest-plugin --jsx-a11y-plugin --nextjs-plugin --react-perf-plugin TEST___FILE.js --fix --fix-suggestions --fix-dangerously

cause this

thread 'main' panicked at /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/oxc-miette-1.0.2/src/handlers/graphical.rs:1026:22:
Formatting argument out of range
stack backtrace:
   0: rust_begin_unwind
             at /rustc/6650252439d4e03368b305c42a10006e36f1545e/library/std/src/panicking.rs:695:5
   1: core::panicking::panic_fmt
             at /rustc/6650252439d4e03368b305c42a10006e36f1545e/library/core/src/panicking.rs:75:14
   2: core::fmt::rt::Argument::from_usize
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/rt.rs:160:13
   3: miette::handlers::graphical::GraphicalReportHandler::render_single_line_highlights::{{closure}}
             at /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/oxc-miette-1.0.2/src/handlers/graphical.rs:1026:22
   4: core::iter::adapters::map::map_fold::{{closure}}
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/adapters/map.rs:88:28
   5: <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::fold
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/iter/macros.rs:255:27
   6: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/adapters/map.rs:128:9
   7: core::iter::traits::iterator::Iterator::for_each
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:800:9
   8: alloc::vec::Vec<T,A>::extend_trusted
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/mod.rs:3566:17
   9: <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/spec_extend.rs:29:9
  10: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/spec_from_iter_nested.rs:62:9
  11: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/spec_from_iter.rs:34:9
  12: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/mod.rs:3425:9
  13: core::iter::traits::iterator::Iterator::collect
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:1980:9
  14: miette::handlers::graphical::GraphicalReportHandler::render_single_line_highlights
             at /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/oxc-miette-1.0.2/src/handlers/graphical.rs:1047:14
  15: miette::handlers::graphical::GraphicalReportHandler::render_context
             at /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/oxc-miette-1.0.2/src/handlers/graphical.rs:616:17
  16: miette::handlers::graphical::GraphicalReportHandler::render_snippets
             at /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/oxc-miette-1.0.2/src/handlers/graphical.rs:496:13
  17: miette::handlers::graphical::GraphicalReportHandler::render_report
             at /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/oxc-miette-1.0.2/src/handlers/graphical.rs:232:9
  18: <oxlint::output_formatter::default::GraphicalReporter as oxc_diagnostics::reporter::DiagnosticReporter>::render_error
             at ./oxc-main/apps/oxlint/src/output_formatter/default.rs:83:9
  19: oxc_diagnostics::service::DiagnosticService::run
             at ./oxc-main/crates/oxc_diagnostics/src/service.rs:209:40
  20: <oxlint::lint::LintRunner as oxlint::runner::Runner>::run
             at ./oxc-main/apps/oxlint/src/lint.rs:373:33
  21: oxlint::main
             at ./oxc-main/apps/oxlint/src/main.rs:23:5
  22: core::ops::function::FnOnce::call_once
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

##### Automatic Fuzzer note, output status "None", output signal "Some(6)"

compressed.zip

@shulaoda
Copy link
Member

I am unable to reproduce your issue:

PS D:\shulaoda\oxlint-repo> pnpm oxlint -D all -D nursery --import-plugin --jsdoc-plugin --jest-plugin --vitest-plugin --jsx-a11y-plugin --nextjs-plugin --react-perf-plugin index.js --fix --fix-suggestions --fix-dangerously   

  ⚠ File is too long to fit on the screen
  help: "index.js" seems like a minified file

Found 0 warnings and 1 error.
Finished in 5ms on 1 file with 485 rules using 20 threads.

BTW, I am using Windows.

@Boshen
Copy link
Member

Boshen commented Mar 14, 2025

I cannot replicate either, and I can't figure out how it could panic in render_single_line_highlights.

@qarmin
Copy link
Author

qarmin commented Mar 14, 2025

With this binary I can reproduce this each time - https://github.com/qarmin/Automated-Fuzzer/releases/download/Nightly/oxlint.7z

This looks like - rust-lang/rust#102528

In CI, this broken between 2025-03-10T21:18:02 - '2025-03-12T21:15:03'

It may be related to overflow-checks that I enable by default in release builds

width seems to have strange value
https://github.com/oxc-project/oxc-miette/blob/8c032f8e915f21dec6dcd2e4f652926452632efa/src/handlers/graphical.rs#L1045-L1058

@Boshen Boshen self-assigned this Mar 17, 2025
@Boshen
Copy link
Member

Boshen commented Mar 17, 2025

Close as not planned until we can replicate this reliably.

@Boshen Boshen closed this as not planned Won't fix, can't repro, duplicate, stale Mar 17, 2025
@qarmin
Copy link
Author

qarmin commented Mar 18, 2025

I was able to reproduce this with newest nightly rust compiler, by compiling oxlint with just

cargo +nightly build

@qarmin
Copy link
Author

qarmin commented Mar 18, 2025

I found also rust commit with change - rust-lang/rust@fb9ce02

@Boshen Boshen reopened this Mar 18, 2025
@Boshen
Copy link
Member

Boshen commented Mar 18, 2025

Ah ok, it's a rustc breaking change, width is reduce to 16 bits. rust-lang/rust#136932

@Boshen
Copy link
Member

Boshen commented Mar 19, 2025

Fixed by oxc-project/oxc-miette#20

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.

3 participants