Repository navigation
Conversation
…m Bytecode UB Address three memory-safety and correctness issues in crates/victory-gpu: - Fix resource::is_aliased to verify target liveness (object::is_alive, refs.load(Acquire) > 0) under TARGETS_AT rather than treating dying refs == 0 targets as aliased, and harden object::add_ref_alive with checked_add(1) overflow protection. - Evict Memory::heaps entry on Heap::drop (adapted from Marvisak#2234): add memory::release_heap keyed by HostHeap pointer address and invoke it in Drop for Heap strictly after dropping the SHADER_HEAPS write guard. - Fix unaligned pipeline stream Bytecode read and guard truncated stream subobjects in pipeline::create_stream (adapted from Marvisak#2301) via read_unaligned(), saturating_sub, and checked_add bounds checks. - Add RAII-guarded unit and D3D12 regression tests for all three fixes.
This was referenced Nov 28, 2026
Dukestar69
approved these changes
Nov 28, 2026
Dukestar69
left a comment
There was a problem hiding this comment.
LGTM — verified on Windows (RTX 5090):
cargo test -p victory-gpu --lib memory::(2/2),object::(5/5, includingadd_ref_alive_and_is_alive_check_refcount_bounds), andpipeline::tests::(2/2) all passed- 0 new compiler warnings in touched files
cargo xtask policypassed (294 files ok)
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
MystifiedSky
added a commit
to MystifiedSky/VIctory-NVIDIA-Improved
that referenced
this pull request
Nov 28, 2026
whoalin1
added a commit
to whoalin1/victory-altracing-prs
that referenced
this pull request
Nov 28, 2026
…s, evict Memory::heaps, guard stream Bytecode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses three correctness and memory-safety issues in
crates/victory-gpu(zero conflict with #646 or #666):Changes
object.rs,resource.rs):object::is_alive(this)(refs.load(Ordering::Acquire) > 0) and updatesresource::is_aliasedfromalias_with(this, |_| ()).is_some()toalias_with(this, crate::object::is_alive).unwrap_or(false)so a dying target withrefs == 0still registered inTARGETS_ATbeforeResource::dropcompletes is not treated as an active alias.object::add_ref_alivewithchecked_add(1)to preventu32::MAXwrap-around.Memory::heapsentry onHeap::drop(adapted fromMarvisak#2234—memory.rs,descriptor.rs):memory::release_heap(key: usize)matchingMemory::heaps'sHostHeappointer key and calls it inDrop for Heapstrictly after dropping theSHADER_HEAPSwrite guard.Bytecoderead & truncated subobject guard (adapted fromMarvisak#2301—pipeline.rs):&*desc.stream.add(at + 8).cast::<Bytecode>()with.read_unaligned()and bounds-checks every subobject withsaturating_sub/checked_addbefore reading payload or callinggraphics.read.Verification
cargo test --locked -p victory-gpu --lib -- add_ref_alive is_alive alias safety_tests -- --test-threads=1(6 passed, 0 failed) and--features diagnostics(5 passed, 0 failed):object::tests::add_ref_alive_and_is_alive_check_refcount_boundsresource::tests::an_alias_source_is_held_after_the_title_releases_it(un-gated to#[cfg(windows)]with RAII cleanup)resource::tests::is_aliased_ignores_dying_target_with_zero_refcountdescriptor::safety_tests::released_view_heap_evicts_memory_heap_entry(RAII-guarded)pipeline::safety_tests::unaligned_stream_yields_its_shaders&truncated_shader_subobject_does_not_read_past_stream(RAII-guarded)--all-features) andcargo test --locked -p xtaskpassed (6 passed, 0 failed, including asset policy).