rust-lang / rust-lang/nomicon

"Working With Uninitialized Memory" makes overly broad claims

Open
#435 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
CSS
Stars
2.3k
Forks
325
PR merge metrics
No merged PRs in 30d

Description

Here, the Nomicon claims

All runtime-allocated memory in a Rust program begins its life as uninitialized. In this state the value of the memory is an indeterminate pile of bits that may or may not even reflect a valid state for the type that is supposed to inhabit that location of memory. Attempting to interpret this memory as a value of any type will cause Undefined Behavior.

That's not true; there are types that allow reading a value from uninitialized memory for some or all of their bytes: MaybeUninit is the obvious example, and more generally unions with a () field (or even all unions, details are TBD). Also, padding bytes are allowed to be uninitialized.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Nomicon page at https://doc.rust-lang.org/nomicon/uninitialized.html and review the quoted claim against the issue's examples involving MaybeUninit, unions, and padding bytes. Revise the wording so it no longer makes an overly broad statement, then check that the page accurately reflects the stated exceptions.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.