gpu: fix alias liveness check, Memory::heaps drop eviction, and stream Bytecode UB #693
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/693"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by mint17 on 2026-11-28T03:36:14Z.
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).Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-28T04:48:17Z.
Review: APPROVED
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 passedcargo xtask policypassed (294 files ok)Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).