Semantics of function pointers with equal addresses?
まだ誰も着手していません。
評価
調査の方向性
Start with the two Rust functions in the issue and reproduce their deduplication using the linked Godbolt example. Trace the implications of converting their equal addresses through usize and consider the analogous deduplicated-vtable case. Done means reaching and documenting a resolved language-semantics position for these cases.
索引モデルが issue の本文から書いたものです。
説明
Consider the following code:
#[unsafe(no_mangle)]
fn foo(x: *mut i32, y: *mut i32) {
unsafe {
let a = &mut *x;
let b = &mut *y;
*a = *b;
}
}
#[unsafe(no_mangle)]
fn bar(x: *mut i32, y: *mut i32) {
unsafe {
x.write(y.read());
}
}
On rust version 1.91.0, the above code compiles to this assembly (Godbolt link):
bar:
mov eax, dword ptr [rsi]
mov dword ptr [rdi], eax
ret
foo = bar
That is, the two functions are deduplicated, and therefore have the same address. This happened even though these two functions have different behavior in the abstract machine: the foo function has UB if x and y alias, while the bar function doesn't.
Suppose that some code casts these two functions into usize addresses (which are equal to each other), does some operation with those two usizes, and then transmutes an equal usize back into a function pointer. When calling that created function pointer, what is the behavior of that call? Does the call behave like calling foo or calling bar?
In theory, we probably also want (in the future) to potentially allow LLVM to deduplicate functions with incompatible ABIs, as long as their generated assembly are identical. This complicates the above question even further.
A similar question applies to deduplicated vtables.
- 主要言語
- 言語のデータがありません
- スター
- 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 日以内に返信