What about: distributed slices (linkme)
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 18/100
調査の方向性
Start with the linked linkme distributed-slice documentation and the cited Rust Reference pull request comment. Compare the Unix __START/__STOP approach with the Windows section-ordering approach, focusing on the aliasing concern described here. Done means recording a clear conclusion about the soundness of the pattern and any applicable guidance.
索引モデルが issue の本文から書いたものです。
説明
I don't think we have an issue tracking this yet. linkme implements distributed slices with linker shenanigans such that it's possible to write #[distributed_slice] pub static ITEMS: [Item]; and use that slice to access any number of #[distributed_slice(ITEMS)] static ITEM: Item = /* … */; safely.
This is implemented by expanding to, very roughly (omitting non-linux support, item type validation, and guards against name clashes):
pub static ITEMS: &[Item] = unsafe {
#[used(linker)]
#[link_section = "linkme_ITEMS"]
static mut __LINKME: [Item; 0] = [];
extern "Rust" {
#[link_name = "__start_linkme_ITEMS"]
static __START: Item;
#[link_name = "__stop_linkme_ITEMS"]
static __STOP: Item;
}
assert!(size_of::<Item>() > 0);
slice::from_ptr_range(
&raw const __START,
&raw const __STOP,
)
};
#[used(linker)]
#[link_section = "linkme_ITEMS"]
static ITEM: Item = /* … */;
Unfortunately, as currently written, I think this should be considered unsound (a case of deliberate UB):
under no circumstances is it fine to access the same underlying global memory with pointers derived from different
staticorextern staticdeclarations (except, probably, those with the same link_name).
Originally posted by @RalfJung in https://github.com/rust-lang/reference/pull/1657#issuecomment-2464241656
Namely, because the static ITEM is accessible through both ITEM and the slice ITEMS. Writing this in a sound manner (the static item is only accessible through a single static name) may be possible, but isn't particularly nice and introduces additional indirection, very roughly:
static ITEM: &Item = unsafe {
#[used(linker)]
#[link_section = "linkme_ITEMS"]
static __LINKME: Item = /* … */;
extern "Rust" {
#[link_name = "__start_linkme_ITEMS"]
static __START: Item;
}
(&raw const __START)
.with_addr_of(&raw const __LINKME)
.as_ref().unwrap_unchecked()
};
…however, on Windows, the situation is even more squirrelly, because __START/__STOP aren't extern static, because Windows doesn't have magic symbols for the boundary of link sections like unixes do. Instead, [Item; 0] statics are created in the right place utilizing section ordering.
- 主要言語
- 言語のデータがありません
- スター
- 760
- フォーク
- 68
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rust-lang/unsafe-code-guidelines のほかの issue
-
I-opsem-nominated
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
rust-lang/unsafe-code-guidelines#634 · コメント 5 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 12/100
rust-lang/unsafe-code-guidelines#632 · コメント 8 件 · リアクション 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 10/100
rust-lang/unsafe-code-guidelines#631 · コメント 7 件 ·
-
I-opsem-nominated
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
rust-lang/unsafe-code-guidelines#630 · リアクション 1 件 ·
rust-lang/unsafe-code-guidelines の issue をすべて見る
似ている issue
-
bug core-lang
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Call-argument syntax diagnostic needs example spacing and removal of confusing trailing sentenceオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
mw00/project-maya#1368 ·
メンテナーはふだん 2 日以内に返信
-
test(bind-json): legacy Solidity fixture requires an unavailable solc on Linux ARM64対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
foundry-rs/foundry#18828 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信