fix(gpu): pin the texture a placed view aliases while the copy uses it
alias_of returned the bare pointer of the aliased texture after TARGETS_AT's lock was gone, and texture::alias then used it; the title can drop its last reference in between (use-after-free, or a copy from the next texture at the same address). alias_of now takes a reference under the lock (object::add_ref_alive) and returns a Held guard that the two copying callers (draw.rs readable, external.rs prepare_input) keep until the alias copy is recorded; a texture already being released is not returned. This tree has three lookup-only callers (draw.rs bake sources, texture/ahead.rs, resource.rs host-copy levels). They now call is_aliased, the same lookup without a pin, so none of them takes and drops a reference (and so none can end up freeing the texture inside its own work). No switch: a lifetime fix with no other behaviour change. The original test comes along (diagnostics builds with a host GPU only). Original author: CwWwWwW (fxceless/victory-fork pull request #1336, f8fab6fb). Ported by hand from CuteBooty/victory-8gb; Held and add_ref_alive follow fxceless/victory-fork d4a528ba, which this tree does not have. Co-Authored-By: Claude Fable 5.2 <[email protected]> (cherry picked from commit 6665ad8bd2147e58aed9362e41718aa385643102)
This commit is contained in:
1 parent
8e9f11d618
commit
74d6f2408b
5 files changed
+100
-7
No files matched your search
@@ -114,7 +114,7 @@ fn claim(resource: This, first: u32, there: u64) -> Option<Taken> {
|
||||
|| copy.holds.lock().unwrap_or_else(|e| e.into_inner()).is_some()
|
||||
|| !crate::pool::fresh(©.texture)
|
||||
|| super::host_wrote(resource as usize)
|
||||
|| crate::resource::alias_of(resource).is_some()
|
||||
|| crate::resource::is_aliased(resource)
|
||||
{
|
||||
return turned_down();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user