rust-lang / rust-lang/glob

Glob panicked because of an out-of-bounds error on the pattern

Open
#134 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
596
Forks
93
PR merge metrics
No merged PRs in 30d

Description

I tried to use a pretty basic pattern, and got the following crash (ran with RUST_BACKTRACE=1):

thread 'main' panicked at C:\Users\cleme\.cargo\registry\src\index.crates.io-6f17d22bba15001f\glob-0.3.1\src\lib.rs:218:32:
byte index 14 is out of bounds of `\\*.custom*\*`
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\std\src\panicking.rs:597
   1: core::panicking::panic_fmt
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\core\src\panicking.rs:72
   2: core::fmt::Arguments::new_v1
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\core\src\fmt\mod.rs:331
   3: core::str::slice_error_fail_rt
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\core\src\str\mod.rs:110
   4: core::str::slice_error_fail
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\core\src\str\mod.rs:87
   5: core::str::traits::impl$9::index
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962\library\core\src\str\traits.rs:361
   6: core::str::traits::impl$4::index<core::ops::range::RangeTo<usize> >
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962\library\core\src\str\traits.rs:61
   7: glob::glob_with
             at C:\Users\cleme\.cargo\registry\src\index.crates.io-6f17d22bba15001f\glob-0.3.1\src\lib.rs:218
   8: <a call from my own crate>

Context:

  • Glob v0.3.1
  • Windows 11 23H2 (not WSL)
  • CWD on D: drive (not C:)
  • Rust v1.74.0

EDIT: Problem doesn't appear when I use \*.custom*\* instead of \\*.custom*\* (removing one of the lead backslashes)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the panic on Windows with the reported doubled-leading-backslash pattern, then inspect glob_with at src/lib.rs:218 using the stack trace as the starting point. Add a regression test for this pattern and verify that glob no longer panics.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.