# Document the invariants of the `unsafe` code in `Repository` (`src/repo.rs`)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- ドキュメント
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- rust
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Rust
- スター
- 2.1k
- フォーク
- 470
- 平均マージ
- 2日 17時間
- マージ済み PR(30日)
- 18
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rust-lang/git2-rs のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
`stash_foreach` crashes on stash entries with no message or a non-UTF-8 message対応中かも @shivampwm2020 が 43 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
rust-lang/git2-rs の issue をすべて見る
似ている issue
-
bug P2
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
Windows microphone listing treats words in a device name as DirectShow labels対応中かも @Sujal-chaudhary が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
clipy-recorder/clipy#447 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
nightly-cleanup
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
max-sixty/worktrunk#4939 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Flaky Test] tests::signer::v0::miner_recovers_when_broadcast_block_delay_across_tenures_occursオープンflaky
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
stacks-network/stacks-core#7918 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信