Skip to content

Out of bounds panic in oxc_span/src/span/mod.rs #6466

@qarmin

Description

@qarmin

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):

switch(s){case'':/]/}

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

cause this

thread '<unnamed>' panicked at crates/oxc_span/src/span/mod.rs:312:21:
byte index 18 is out of bounds of ``
stack backtrace:
   0: rust_begin_unwind
             at /rustc/52fd9983996d9fcfb719749838336be66dee68f9/library/std/src/panicking.rs:665:5
   1: core::panicking::panic_fmt
             at /rustc/52fd9983996d9fcfb719749838336be66dee68f9/library/core/src/panicking.rs:74:14
   2: core::str::slice_error_fail_rt
   3: core::str::slice_error_fail
             at /rustc/52fd9983996d9fcfb719749838336be66dee68f9/library/core/src/str/mod.rs:68:5
   4: core::str::traits::<impl core::slice::index::SliceIndex<str> for core::ops::range::Range<usize>>::index
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/traits.rs:240:21
   5: core::str::traits::<impl core::ops::index::Index<I> for str>::index
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/traits.rs:60:15
   6: oxc_span::span::<impl oxc_span::span::types::Span>::source_text
             at ./oxc-main/crates/oxc_span/src/span/mod.rs:312:21
   7: oxc_ast::ast_impl::literal::<impl oxc_ast::ast::literal::RegExpPattern>::source_text
             at ./oxc-main/crates/oxc_ast/src/ast_impl/literal.rs:140:49
   8: <oxc_ast::ast::literal::RegExpLiteral as oxc_codegen::gen::Gen>::gen
             at ./oxc-main/crates/oxc_codegen/src/gen.rs:1198:28
   9: oxc_codegen::gen::Gen::print
             at ./oxc-main/crates/oxc_codegen/src/gen.rs:22:9
  10: <oxc_ast::ast::js::Expression as oxc_codegen::gen::GenExpr>::gen_expr
             at ./oxc-main/crates/oxc_codegen/src/gen.rs:1010:45
  11: oxc_codegen::gen::GenExpr::print_expr
             at ./oxc-main/crates/oxc_codegen/src/gen.rs:30:9
  12: oxc_codegen::Codegen::print_expression
             at ./oxc-main/crates/oxc_codegen/src/lib.rs:237:9
  13: <oxc_ast::ast::js::ExpressionStatement as oxc_codegen::gen::Gen>::gen
             at ./oxc-main/crates/oxc_codegen/src/gen.rs:151:9
  14: <oxc_linter::rules::unicorn::switch_case_braces::SwitchCaseBraces as oxc_linter::rule::Rule>::run::{{closure}}::{{closure}}
             at ./oxc-main/crates/oxc_linter/src/rules/unicorn/switch_case_braces.rs:94:55
  15: <core::slice::iter::Iter<T> as 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/slice/iter/macros.rs:254:21
  16: <oxc_linter::rules::unicorn::switch_case_braces::SwitchCaseBraces as oxc_linter::rule::Rule>::run::{{closure}}
             at ./oxc-main/crates/oxc_linter/src/rules/unicorn/switch_case_braces.rs:92:37
  17: oxc_linter::context::LintContext::diagnostic_with_fix_of_kind
             at ./oxc-main/crates/oxc_linter/src/context/mod.rs:297:37
  18: oxc_linter::context::LintContext::diagnostic_with_fix
             at ./oxc-main/crates/oxc_linter/src/context/mod.rs:228:9
  19: <oxc_linter::rules::unicorn::switch_case_braces::SwitchCaseBraces as oxc_linter::rule::Rule>::run
             at ./oxc-main/crates/oxc_linter/src/rules/unicorn/switch_case_braces.rs:75:29
  20: oxc_linter::Linter::run
             at ./oxc-main/crates/oxc_linter/src/lib.rs:139:17
  21: oxc_linter::service::runtime::Runtime::process_source
             at ./oxc-main/crates/oxc_linter/src/service/runtime.rs:291:9
  22: oxc_linter::service::runtime::Runtime::process_path
             at ./oxc-main/crates/oxc_linter/src/service/runtime.rs:142:32
  23: oxc_linter::service::LintService::run::{{closure}}
             at ./oxc-main/crates/oxc_linter/src/service/mod.rs:96:59
  24: <rayon::iter::map_with::MapWithFolder<C,U,F> as rayon::iter::plumbing::Folder<T>>::consume
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.10.0/src/iter/map_with.rs:304:27
  25: <&rayon::iter::par_bridge::IterParallelProducer<Iter> as rayon::iter::plumbing::UnindexedProducer>::fold_with
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.10.0/src/iter/par_bridge.rs:145:30
  26: rayon::iter::plumbing::bridge_unindexed_producer_consumer
  27: rayon::iter::plumbing::bridge_unindexed_producer_consumer::{{closure}}
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.10.0/src/iter/plumbing/mod.rs:473:31
  28: rayon_core::join::join_context::call_a::{{closure}}
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/join/mod.rs:124:17
  29: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:272:9
  30: std::panicking::try::do_call
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:557:40
  31: std::panicking::try
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:520:19
  32: std::panic::catch_unwind
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:358:14
  33: rayon_core::unwind::halt_unwinding
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/unwind.rs:17:5
  34: rayon_core::join::join_context::{{closure}}
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/join/mod.rs:142:24
  35: rayon_core::join::join_context
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/join/mod.rs:132:5
  36: rayon::iter::plumbing::bridge_unindexed_producer_consumer
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.10.0/src/iter/plumbing/mod.rs:472:51
  37: rayon::iter::plumbing::bridge_unindexed_producer_consumer::{{closure}}
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.10.0/src/iter/plumbing/mod.rs:473:31
  38: rayon_core::join::join_context::call_a::{{closure}}
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/join/mod.rs:124:17
  39: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:272:9
  40: std::panicking::try::do_call
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:557:40
  41: std::panicking::try
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:520:19
  42: std::panic::catch_unwind
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:358:14
  43: rayon_core::unwind::halt_unwinding
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/unwind.rs:17:5
  44: rayon_core::join::join_context::{{closure}}
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/join/mod.rs:142:24
  45: rayon_core::join::join_context
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/join/mod.rs:132:5
  46: rayon::iter::plumbing::bridge_unindexed_producer_consumer
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.10.0/src/iter/plumbing/mod.rs:472:51
  47: rayon::iter::plumbing::bridge_unindexed_producer_consumer::{{closure}}
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.10.0/src/iter/plumbing/mod.rs:473:31
  48: rayon_core::join::join_context::call_a::{{closure}}
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/join/mod.rs:124:17
  49: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:272:9
  50: std::panicking::try::do_call
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:557:40
  51: std::panicking::try
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:520:19
  52: std::panic::catch_unwind
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:358:14
  53: rayon_core::unwind::halt_unwinding
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/unwind.rs:17:5
  54: rayon_core::join::join_context::{{closure}}
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/join/mod.rs:142:24
  55: rayon_core::join::join_context
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/join/mod.rs:132:5
  56: rayon::iter::plumbing::bridge_unindexed_producer_consumer
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.10.0/src/iter/plumbing/mod.rs:472:51
  57: rayon::iter::plumbing::bridge_unindexed
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.10.0/src/iter/plumbing/mod.rs:451:5
  58: <rayon::iter::par_bridge::IterBridge<Iter> as rayon::iter::ParallelIterator>::drive_unindexed
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.10.0/src/iter/par_bridge.rs:91:9
  59: <rayon::iter::map_with::MapWith<I,T,F> as rayon::iter::ParallelIterator>::drive_unindexed
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.10.0/src/iter/map_with.rs:53:9
  60: rayon::iter::from_par_iter::<impl rayon::iter::FromParallelIterator<()> for ()>::from_par_iter
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.10.0/src/iter/from_par_iter.rs:308:9
  61: rayon::iter::ParallelIterator::collect
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.10.0/src/iter/mod.rs:2069:9
  62: rayon::iter::ParallelIterator::for_each_with
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.10.0/src/iter/mod.rs:417:33
  63: oxc_linter::service::LintService::run
             at ./oxc-main/crates/oxc_linter/src/service/mod.rs:96:14
  64: <oxlint::lint::LintRunner as oxlint::runner::Runner>::run::{{closure}}
             at ./oxc-main/apps/oxlint/src/lint/mod.rs:150:17
  65: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:272:9
  66: std::panicking::try::do_call
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:557:40
  67: std::panicking::try
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:520:19
  68: std::panic::catch_unwind
             at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:358:14
  69: rayon_core::unwind::halt_unwinding
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/unwind.rs:17:5
  70: rayon_core::registry::Registry::catch_unwind
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/registry.rs:367:27
  71: rayon_core::spawn::spawn_job::{{closure}}
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/spawn/mod.rs:97:13
  72: <rayon_core::job::HeapJob<BODY> as rayon_core::job::Job>::execute
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/job.rs:169:9
  73: rayon_core::job::JobRef::execute
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/job.rs:64:9
  74: rayon_core::registry::WorkerThread::execute
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/registry.rs:860:13
  75: rayon_core::registry::WorkerThread::wait_until_cold
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/registry.rs:794:26
  76: rayon_core::registry::WorkerThread::wait_until
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/registry.rs:769:13
  77: rayon_core::registry::WorkerThread::wait_until_out_of_work
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/registry.rs:818:9
  78: rayon_core::registry::main_loop
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/registry.rs:923:5
  79: rayon_core::registry::ThreadBuilder::run
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/registry.rs:53:18
  80: <rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{{closure}}
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/registry.rs:98:20
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

Metadata

Metadata

Assignees

Labels

C-bugCategory - Bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions