vt_shell: command spans are character indices but sliced as bytes (plan.rs:185)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 78/100
Direzione di ricerca
Inizia da crates/vt_shell/src/lib.rs:95 e verifica come l'intervallo da SourcePosition viene utilizzato in crates/vt_plan/src/plan.rs alle righe 185, 266 e 281. Esegui la riproduzione fornita in package.json, quindi aggiungi o esegui una regressione che copra un comando non ASCII e verifica che vp run termini senza uno slice panic.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
vt_shell: command spans are character indices but sliced as bytes (plan.rs:185)
vp run <script> aborts with a slice panic before the script runs when the
script's command string contains a non-ASCII character. The Range<usize>
returned by try_parse_as_and_list counts characters, but every consumer
slices the command string by bytes, so the range can end in the middle of a
multi-byte character.
Reproduced with vp v0.3.0 (vite-task rev d05b1dc), macOS 26.6.2 arm64.
Filing here rather than on the vite-plus tracker the panic handler points at,
since the code lives in this repo — happy to move it if you prefer.
Panic
thread '<unnamed>' (28859855) panicked at crates/vt_plan/src/plan.rs:185:65:
end byte index 78 is not a char boundary; it is inside '置' (bytes 77..80 of string)
Reproduction
A package.json is the whole repro — no dependencies, no install:
{
"name": "pm-probe",
"version": "1.0.0",
"scripts": {
"whoami": "node -e \"console.log('agent =', process.env.npm_config_user_agent || '(未设置)')\""
}
}
$ vp run whoami
thread '<unnamed>' panicked at crates/vt_plan/src/plan.rs:185:65:
end byte index 78 is not a char boundary; it is inside '置' (bytes 77..80 of string)
The command string is 78 characters but 84 bytes, and its last multi-byte
character 置 occupies bytes 77..80 — so the character-based end index 78 lands
inside it. Position matters, not merely the presence of non-ASCII: the same
script with the Chinese text earlier in the line happens to survive, because the
byte index it produces is still a valid boundary (it just slices the wrong text).
Root cause
crates/vt_shell/src/lib.rs:95:
fn pipeline_to_command(pipeline: &Pipeline) -> Option<(TaskParsedCommand, Range<usize>)> {
let location = pipeline.location()?;
let range = location.start.index..location.end.index;
brush_parser::tokenizer::SourcePosition::index is documented as
The 0-based index of the character in the input stream.
while every consumer of that range slices a &str, i.e. by byte:
crates/vt_plan/src/plan.rs:185— the panic sitecrates/vt_plan/src/plan.rs:266crates/vt_plan/src/plan.rs:281
(The same range is also stored through Context::push_stack_frame, though
nothing slices with it today.)
All three sites sit under the // Build execution display comment, so what
aborts the run is display bookkeeping, not the work itself.
- Lingua principale
- Rust
- Stelle
- 466
- Fork
- 42
- Merge medio
- 1g 20h
- PR unite (30g)
- 21
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di voidzero-dev/vite-task
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
voidzero-dev/vite-task#738 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
voidzero-dev/vite-task#717 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
voidzero-dev/vite-task#702 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
voidzero-dev/vite-task#700 · 2 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 78/100
voidzero-dev/vite-task#699 ·
Tutte le issue di voidzero-dev/vite-task
Issue simili
-
has_tail_capacity wraps and get_writable_raw_unchecked commits raw_len before the bounds check Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
stratum-mining/stratum#2404 ·
-
bug ci good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
documentation easy help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
lacs-project/sysknife#483 · 1 commento ·
-
area:evidence documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
registrystack/registry-stack#1302 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100