A process's exit runs its exit handlers and its libraries' destructors on the
exiting thread while the library's other threads go on. A device's display let
go as a test process exited made its last vaTerminate on the device's thread
beside the driver's exit-time destructors: on the Iris Xe (intel-media-driver
26.3.5) test processes aborted after "ok" in iHD's frees, "double free or
corruption (out)" and "free(): invalid pointer", in 2 of 90 runs of the
workspace's tests. A host that quits with a display open meets the same race.
Two holes let the call through. The exit gate's handler was last registered
before vaInitialize loaded the driver, so the driver's destructors ran before
it; and the VA crate's Calls made its at-once calls on the caller's thread
(where its call thread is idle, and in its paths with no thread) without a
step of the gate. The video runtime now registers the gate's handler again
after each vaInitialize (Runtime::arm_exit, the platform runtime's
exit_gate::arm), and every VA call takes a step, so the exit waits out a call
in progress before the driver's destructors run, and parks a thread that
would make the next.
For the host: a process that exits with a VA display open no longer aborts in
the driver; a thread that would call VA once the exit began parks until the
process ends. The C API's release is unchanged.
no_call_runs_beside_a_drivers_exit_time_destructors holds the pattern without
a driver: a child process with a stand-in for the driver's destructors and a
runtime gated as the host's exits while another thread makes Calls' at-once
calls; without the steps the child ends as a call reaches the stand-in after
its destructors ran.