rust-embedded / rust-embedded/cortex-m
`cortex_m::singleton` attribute forwarding is unsound in some cases
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1k
- Forks
- 202
- Avg merge
- 6d 2h
- Merged PRs (30d)
- 2
Description
If you use link_section to put a singleton in an uninit section, the "has been taken" boolean is also in uninit memory at startup. We read this value which is uninitialized.
We could potentially put the bool in a separate static that is in the "normal" .bss section, but we'd have to document this.
CC @jordens and https://github.com/rust-embedded/cortex-m/pull/522
Contributor guide
No contributing guide indexed for this repository
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
Start with cortex-m/src/macros.rs at lines 72-74 and review the context around PR 522. Trace how link_section is forwarded to the singleton and how the “has been taken” boolean is placed, then confirm that the fix avoids reading it from uninitialized memory and documents the resulting section behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100