oxidecomputer / oxidecomputer/hubris
hiffy use of mutable statics is possibly unsound
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.6k
- Forks
- 239
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 23
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read task/hiffy/src/main.rs around line 173 and trace the declaration and uses of HIFFY_DATA. Run the hiffy build with the latest toolchain; done means the mutable-static warning is resolved and the access is established as sound.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- embedded-iot, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100