Document remaining unsafe blocks in victory-gpu and re-enable undocumented_unsafe_blocks #11

Open
opened 2026-12-06 00:20:08 +00:00 by github-bot · 0 comments
Owner

@⁠VictoryX-dev on GitHub · 2026-12-03 02:57 UTC · original

Problem

runtime/Cargo.toml currently relaxes Clippy's undocumented_unsafe_blocks lint (undocumented_unsafe_blocks = "allow") because a small number of unsafe blocks in newer victory-gpu code still lack // SAFETY: justifications. Documenting these remaining blocks lets the workspace enforce safety comments on every unsafe block going forward.

Known Evidence

  • Observed directly in runtime/Cargo.toml (lines 63–65):
    • Comment explicitly notes: "Upstream warns on unsafe blocks without a SAFETY comment; eleven blocks in this fork's newer GPU code still lack one."
    • unsafe_op_in_unsafe_fn = "deny" is already active workspace-wide.
  • Synthetic / Local verification: Easily verified locally with cargo clippy --workspace --all-targets --all-features --locked -- -D warnings (no title files or GPU hardware required).

Approaches That Did Not Work

  • Adding boilerplate // SAFETY: safe comments: Safety comments must state the actual invariant upheld by the caller or surrounding code (e.g., pointer alignment/lifetime, COM precondition, slice bounds, lock held).

Relevant Source Modules

  • runtime/Cargo.toml (lines 47–65)
  • runtime/crates/victory-gpu/src/ (locate undocumented blocks by temporarily switching undocumented_unsafe_blocks = "warn" and running cargo clippy)

Expected Contribution

  1. Change undocumented_unsafe_blocks = "allow" to "warn" in runtime/Cargo.toml.
  2. Run cargo clippy --workspace --all-targets --locked and cargo clippy --workspace --all-targets --all-features --locked to list every undocumented unsafe block.
  3. Audit each flagged unsafe block and write a concise, accurate // SAFETY: comment explaining the exact invariant that makes it sound (or flag any genuinely suspect invariant in the PR for maintainer review).
  4. Keep undocumented_unsafe_blocks = "warn" in runtime/Cargo.toml so CI enforces it permanently.

Acceptance Criteria

  • undocumented_unsafe_blocks = "warn" is enabled in runtime/Cargo.toml.
  • Both cargo clippy --workspace --all-targets --locked -- -D warnings and --all-features pass with zero warnings.
  • Every new // SAFETY: comment explains concrete preconditions rather than generic placeholders.
**@⁠VictoryX-dev** on GitHub · 2026-12-03 02:57 UTC · [original](https://github.com/VictoryX-dev/VictoryX/issues/11) ## Problem `runtime/Cargo.toml` currently relaxes Clippy's `undocumented_unsafe_blocks` lint (`undocumented_unsafe_blocks = "allow"`) because a small number of `unsafe` blocks in newer `victory-gpu` code still lack `// SAFETY:` justifications. Documenting these remaining blocks lets the workspace enforce safety comments on every `unsafe` block going forward. ## Known Evidence - **Observed directly in `runtime/Cargo.toml` (lines 63–65):** - Comment explicitly notes: *"Upstream warns on unsafe blocks without a SAFETY comment; eleven blocks in this fork's newer GPU code still lack one."* - `unsafe_op_in_unsafe_fn = "deny"` is already active workspace-wide. - **Synthetic / Local verification:** Easily verified locally with `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` (no title files or GPU hardware required). ## Approaches That Did Not Work - **Adding boilerplate `// SAFETY: safe` comments:** Safety comments must state the *actual* invariant upheld by the caller or surrounding code (e.g., pointer alignment/lifetime, COM precondition, slice bounds, lock held). ## Relevant Source Modules - `runtime/Cargo.toml` (lines 47–65) - `runtime/crates/victory-gpu/src/` (locate undocumented blocks by temporarily switching `undocumented_unsafe_blocks = "warn"` and running `cargo clippy`) ## Expected Contribution 1. Change `undocumented_unsafe_blocks = "allow"` to `"warn"` in `runtime/Cargo.toml`. 2. Run `cargo clippy --workspace --all-targets --locked` and `cargo clippy --workspace --all-targets --all-features --locked` to list every undocumented `unsafe` block. 3. Audit each flagged `unsafe` block and write a concise, accurate `// SAFETY:` comment explaining the exact invariant that makes it sound (or flag any genuinely suspect invariant in the PR for maintainer review). 4. Keep `undocumented_unsafe_blocks = "warn"` in `runtime/Cargo.toml` so CI enforces it permanently. ## Acceptance Criteria - [ ] `undocumented_unsafe_blocks = "warn"` is enabled in `runtime/Cargo.toml`. - [ ] Both `cargo clippy --workspace --all-targets --locked -- -D warnings` and `--all-features` pass with zero warnings. - [ ] Every new `// SAFETY:` comment explains concrete preconditions rather than generic placeholders.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-06 00:20:08 +00:00
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/VictoryX-dev--VictoryX#11
No description provided.