Skip to content

Extern statics can be accessed in safe Rust #35112

Closed
@bjorn3

Description

@bjorn3

This code crashes:

#[no_mangle] pub static X: usize = 0;
mod test {
    extern {
        pub static X: &'static u32;
    }
}
fn main() {
     println!("{}", X);
     println!("{}", *test::X);
}

@ubsan wrote this code on irc.
https://botbot.me/mozilla/rust-internals/2016-07-28/?msg=70411962&page=5

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessT-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions