Should immutable statics be allowed to overlap?
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Nessun dato sulla lingua
- Stelle
- 760
- Fork
- 68
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di rust-lang/unsafe-code-guidelines
-
I-opsem-nominated
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
rust-lang/unsafe-code-guidelines#634 · 5 commenti ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 12/100
rust-lang/unsafe-code-guidelines#632 · 8 commenti · 1 reazione ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
rust-lang/unsafe-code-guidelines#631 · 7 commenti ·
-
I-opsem-nominated
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
rust-lang/unsafe-code-guidelines#630 · 1 reazione ·
Tutte le issue di rust-lang/unsafe-code-guidelines
Issue simili
-
bug core-lang
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Call-argument syntax diagnostic needs example spacing and removal of confusing trailing sentenceAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
mw00/project-maya#1368 ·
I maintainer di solito rispondono entro 2 giorni
-
test(bind-json): legacy Solidity fixture requires an unavailable solc on Linux ARM64Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
foundry-rs/foundry#18828 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno