# Document the invariants of the `unsafe` code in `Repository` (`src/repo.rs`)
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ó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rust
- Lĩnh vực
- documentation
Hướng nghiên cứu
Start with the unsafe blocks in src/repo.rs from the constructors through branch_from_annotated_commit, plus unsafe impl Send for Repository, Drop, RepositoryInitOptions::raw and Binding::from_raw. Read the libgit2 ownership rules for each call before writing anything. Done means each block in that range has a // SAFETY: comment stating its invariant, and clippy::undocumented_unsafe_blocks passes for that section. The issue's three lifetime and thread-safety concerns are separate issues and should not be fixed here.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
While auditing the first part of src/repo.rs at db31ed4 (constructors, open*/init*, getters
and setters through branch_from_annotated_commit, the foreach trampolines, Drop, Send,
RepositoryInitOptions), we found that none of its 85 unsafe blocks, nor unsafe impl Send for Repository, states the invariant it relies on. Checking them by hand, most hold, but several
implicit invariants do not:
- C strings returned as
&Path/&strare assumed to live as long as&self. That fails for
workdir()(freed byset_workdir(&self)),namespace()(freed byset_namespace(&self)) and
get_attr()(freed by the next attribute lookup).path()andcommondir()are fine. Send for Repositoryassumes nothing left on the old thread shares state with the repository.
index()andconfig()return lifetime-free handles to the repository's own cached objects, so
that does not hold.set_refdb/set_configassume the installed object does not point back at another repository.
For refdbs and repository configs it does.
Each of these is a separate issue with an AddressSanitizer or ThreadSanitizer trace.
Two smaller points on the public unsafe surface:
<Repository as Binding>::from_rawtakes ownership (Dropcallsgit_repository_free), but
Binding::from_raw's# Safetyonly says the pointer "must be valid".RepositoryInitOptions::rawisunsafe, but calling it has no precondition. Only dereferencing
the pointers it returns does, and that is alreadyunsafe. It could be a safefn.
A // SAFETY: comment per block would make these invariants reviewable, and
clippy::undocumented_unsafe_blocks can enforce it. The full per-site table is available on
request.
Found by Crustify, an experimental
UB/soundness auditing agent developed at UC Berkeley and running on Claude Opus 5.5, then
manually reviewed and independently reproduced.
- Ngôn ngữ chính
- Rust
- Star
- 2.1k
- Fork
- 470
- Merge trung bình
- 2 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 18
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rust-lang/git2-rs
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
`stash_foreach` crashes on stash entries with no message or a non-UTF-8 messageCó thể đã có người làm @shivampwm2020 đã nhận 43 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của rust-lang/git2-rs
Issue tương tự
-
bug P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Windows microphone listing treats words in a device name as DirectShow labelsCó thể đã có người làm @Sujal-chaudhary đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
clipy-recorder/clipy#447 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
nightly-cleanup
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
max-sixty/worktrunk#4939 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Flaky Test] tests::signer::v0::miner_recovers_when_broadcast_block_delay_across_tenures_occursĐang mởflaky
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
stacks-network/stacks-core#7918 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày