Should immutable statics be allowed to overlap?
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Sin datos de lenguaje
- Estrellas
- 760
- Forks
- 68
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de rust-lang/unsafe-code-guidelines
-
I-opsem-nominated
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
rust-lang/unsafe-code-guidelines#634 · 5 comentarios ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 12/100
rust-lang/unsafe-code-guidelines#632 · 8 comentarios · 1 reacción ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 10/100
rust-lang/unsafe-code-guidelines#631 · 7 comentarios ·
-
I-opsem-nominated
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
rust-lang/unsafe-code-guidelines#630 · 1 reacción ·
Todos los issues de rust-lang/unsafe-code-guidelines
Issues similares
-
bug core-lang
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Call-argument syntax diagnostic needs example spacing and removal of confusing trailing sentenceAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
mw00/project-maya#1368 ·
Los mantenedores suelen responder en 2 días
-
test(bind-json): legacy Solidity fixture requires an unavailable solc on Linux ARM64Posiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
foundry-rs/foundry#18828 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día