Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hiffy use of mutable statics is possibly unsound #1726

Open
cbiffle opened this issue Apr 4, 2024 · 0 comments
Open

hiffy use of mutable statics is possibly unsound #1726

cbiffle opened this issue Apr 4, 2024 · 0 comments

Comments

@cbiffle
Copy link
Collaborator

cbiffle commented Apr 4, 2024

With the latest toolchain update we're getting these warnings from hiffy.

warning: creating a shared reference to mutable static is discouraged
   --> task/hiffy/src/main.rs:173:29
    |
173 |         let data = unsafe { &HIFFY_DATA };
    |                             ^^^^^^^^^^^ shared reference to mutable static
    |
    = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
    = note: this will be a hard error in the 2024 edition
    = note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
help: use `addr_of!` instead to create a raw pointer
    |
173 |         let data = unsafe { addr_of!(HIFFY_DATA) };
    |                             ~~~~~~~~~~~~~~~~~~~~

I can't convince myself by local inspection that what the task is doing with statics is sound. Someone more familiar with the code will need to go in there and fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant