Should immutable statics be allowed to overlap?
まだ誰も着手していません。
評価
調査の方向性
Read the linked Rust Reference PR #2334 and its discussion, then review the linked LLVM discussion about immutable static overlap and the Zulip thread on linker section slice iteration. Determine what LLVM changes would permit this pattern while preserving the relevant provenance rules; done means the overlap behavior is resolved well enough to address the linkme undefined behavior.
索引モデルが issue の本文から書いたものです。
説明
This came up in https://github.com/rust-lang/reference/pull/2334 which in the end went forward without blessing this pattern:
// Access a "linker section slice" spanned between `whatever.start` and `whatever.end`.
// Assumption: both are usize-aligned and there's an implicit list of usizes stored between them.
unsafe extern "C" {
#[link_name = "whatever.start"]
static START: [usize; 0];
#[link_name = "whatever.end"]
static END: [usize; 0];
}
/// Call the callback on each element of the "linker section slice".
#[allow(static_mut_refs)] // we immediately decay them to raw pointers
pub fn iter(mut callback: impl FnMut(usize)) { unsafe {
let mut ptr = START.as_ptr();
while ptr.addr() != END.as_ptr().addr() {
callback(ptr.read());
ptr = ptr.add(1);
}
} }
The problem is that the statics which are being put into this section overlap with START:
#[link_section = ".whatever"]
#[used]
static MY_PART: usize = 15; // can also be an array of `usize`
That's UB according to the rule that distinct statics must not overlap.
https://github.com/dtolnay/linkme currently has UB due to this. Cc @dtolnay (https://github.com/dtolnay/linkme/issues/133)
To fix this we'd have to get LLVM to allow immutable statics to overlap. There were concerns that this would require changes to LLVM's logic that go beyond what is needed to fix provenance in general, see this example and discussion. Cc @nikic
Also see Zulip: #t-opsem > linker section slice iteration
- 主要言語
- 言語のデータがありません
- スター
- 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 日以内に返信