Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Preserve truncation errors when bounded C-string copy uses the same buffer

Aperta Adatta ai principianti
#854 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
backend

Direzione di ricerca

Inizia da std/mem/cstr.wave in mem_copy_cstr_n, la posizione collegata nell’issue. Esamina come verifica il troncamento e scrive il terminatore, quindi esegui la riproduzione fornita con -O0 e -O2. Aggiungi regressioni per l’aliasing esatto e i casi limite elencati; il lavoro è terminato quando lo stato e i byte di output corrispondono ai criteri di completamento.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug good first issue

Problem

mem_copy_cstr_n writes its terminating NUL before checking whether the source was truncated. When source and destination are identical, that write changes the byte being checked and turns truncation into a successful byte count.

Starting point: mem_copy_cstr_n.

Reproduction

Audited canonical master 7a8361d5c10ec3e66fc9fe4a5801622afb6bf631 on Linux amd64. Reproduced with the public v0.2.1-pre-beta Linux amd64 compiler (LLVM 21.1.8) and this checkout's std; the compiler/std source trees match the release. Set WAVEC to the extracted package's absolute wavec path and run commands from the repository root.

import("std::mem::cstr")::{mem_copy_cstr_n};
fun main() -> i32 {
    var buf: array<u8, 6> = [97, 98, 99, 100, 101, 0];
    var result: i64 = mem_copy_cstr_n(&buf[0], 3, &buf[0] as str);
    println("result={} bytes={} {} {}", result, buf[0], buf[1], buf[2]);
    return 0;
}

Run "$WAVEC" --std-root "$PWD/std" -O0 run repro.wave, then repeat at -O2. Observed: result=2 bytes=97 98 0. The original five-byte string does not fit; the return must report MEM_ERR_NO_SPACE (-4097), as the non-aliasing copy does.

Scope

Preserve the existing bounded-prefix/NUL behavior and error constants. Cover exact source/destination identity; this issue does not require adding general memmove semantics for every partial overlap. Difficulty: easy.

Completion criteria

  • Exact-alias truncation reports no-space before the original source information is lost.
  • Exact fit, capacity one, empty source, and separate-source copies retain their results.
  • O0/O2 regressions check both output bytes and status.
Lingua principale
Rust
Stelle
56
Fork
21
Merge medio
5h 2m
PR unite (30g)
56

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di wavefnd/Wave

Tutte le issue di wavefnd/Wave

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.