Device::begin_draw_replay_kernels (RUNTIME 2330) hands the pool one piece that
makes the draw replay's three kernels after the creation of a render state that
supports indirect command buffers, and the creation waits for none of them. The
piece upgraded a weak handle of the device, which device/holds.rs counts as a
program handle. A program that dropped its last handles while the piece was
still making a kernel had its drop return with the device live. The pool's
thread then let the device go last, and an exit meanwhile left that teardown
undone.
On NVIDIA's driver the exit handler of libEGL_nvidia then faults on the live
VkDevice (docs/FAST-PATHS.md, known gaps). This is
render_fold::an_execution_of_render_commands_ends_its_group's SIGSEGV after it
passed, on the RTX 3090 and the RTX 5080 Laptop GPU. The 5080's core
(systemd-coredump, job 31206) has the main thread in exit() inside
libEGL_nvidia's exit handler, in libnvidia-eglcore. No runtime thread was in a
Vulkan call, and the device's shader-cache worker was still alive; that worker
stops only in the device's teardown.
Now the piece takes the device as one of the runtime's holders
(WeakDevice::hold, Holder::DrawReplayKernels) for each kernel's making, lets it
go between kernels, and reads holds_go_on before each one. The program's last
drop stops it at its next kernel and waits for the one it is making, so the
device is torn down on the program's thread before that drop returns. The
creation still waits for none of the kernels.
Test: teardown_threads::a_running_draw_replay_kernels_making_leaves_the_device_to_the_program_s_thread.
An ICB-capable state's creation starts the making, which is held before a kernel
while it holds the device. The program drops the state and the device, and the
test asserts the teardown ended on the program's thread before the drop
returned.