Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#854 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu với std/mem/cstr.wave tại mem_copy_cstr_n, vị trí được liên kết trong issue. Kiểm tra cách hàm này xác thực việc cắt cụt và ghi ký tự kết thúc, sau đó chạy ví dụ tái hiện được cung cấp với -O0 và -O2. Thêm các kiểm thử hồi quy cho trường hợp alias chính xác và các trường hợp biên được liệt kê; công việc được xem là hoàn tất khi trạng thái và các byte đầu ra khớp với tiêu chí hoàn thành.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
Rust
Star
56
Fork
21
Merge trung bình
5 giờ 2 phút
Pull request đã merge (30 ngày)
56

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của wavefnd/Wave

Tất cả issue của wavefnd/Wave

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.