Files
metal2vulkan/crates/metal2vulkan-runtime/src/host_ram
Anees Iqbal 2b8b56617d An object a recovery carries answers the caller's own device handle
What: the public device() of every object whose borrow reached a handle a
recovery lets go of answers an owned Device, a clone of the generation
handle it read: Buffer, Texture, Heap, IndirectCommandBuffer, Event, Fence,
SamplerState, Library, Function, DepthStencilState, AddressPool,
DynamicLibrary, BinaryArchive and SharedTextureHandle (whose device is its
texture's). The runtime's own reads keep a borrow through a crate-private
generation() on the types they read it of (Buffer, Texture, Heap,
IndirectCommandBuffer, SamplerState, Function, BinaryArchive): 301 call
sites, so no hot path pays a clone. Each changed item's doc says the handle
is the caller's and keeps its generation, VkDevice included, while held,
past a recovery that carries the object on; MadeOn's doc states that no
borrow of it reaches the program. The validation lane's four callers that
passed the borrow on take a reference of the handle. Signature table
re-blessed (14 rows).

Why: these accessors answered a borrow into device/carry.rs's MadeOn (a
Buffer's or Event's parts, or a LineDevice's GenerationLink), whose
let_go drops that Device at the lost generation's rest while the object
lives. Safe code that held the borrow across a recovery and that rest read
a dropped Device. Metal's device property answers a retained device. The
other objects' device() (queues, command buffers, argument encoders, rate
maps, pipeline states and their function tables) answer a borrow of a
handle the object owns for its life, which no recovery lets go of.

Verified: the lane that follows runs tests::device_recovery_handles before
(it fails: one live VkDevice while the borrow is held) and after the fix;
a workspace check of the accessor change was clean under the plain cfg and
found the four validation callers under m2v_gpu and m2v_cpu_icd (job
m3-max-23584 on a probe commit).
2026-11-12 18:11:56 -08:00
..