🐛 Open the VA-API hardware tests' displays on the gated runtime
The host opens its VA displays on a runtime with an exit gate, armed after vaInitialize loads the driver, so no call of the crate's runs beside the driver's exit-time destructors. The hardware tests opened theirs on StdRuntime, which has no gate. A display's call thread and the thread that keeps work past its deadline call the driver on threads of their own, and a test returns while they still may: Lingering stops counting a kept session before it drops it, and the display's releases are made behind the caller. On the Iris Xe (iHD), pin 47's leg m3-max-19907 ran vaapi::va::wait::gpu::an_encode_still_running_at_its_deadline_is_kept_until_it_is_done, printed "ok", and then the process aborted with "double free or corruption (out)": the encode's kept session was let go while the process exited. Every test that opens a display of the hardware (wait::gpu, encoder, import_check, target_check, target_probe) now opens it on GatedRuntime, whose hook runs before the driver's destructors and waits out the calls in progress. The product is unchanged.
This commit is contained in:
1 parent
aa5773a1c4
commit
b52eea52f2
6 files changed
+19
-12
No files matched your search
@@ -312,10 +312,9 @@ impl VideoEncoder {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::core::runtime::StdRuntime;
|
||||
|
||||
use super::*;
|
||||
use crate::codec::encode::Plane;
|
||||
use crate::vaapi::va::gated::GatedRuntime;
|
||||
|
||||
/// On the driver, 24 encoders made from one display one after another, each dropped before
|
||||
/// the next, the profiles the driver encodes in turn, code each of their 4 frames: a dropped
|
||||
@@ -324,7 +323,7 @@ mod tests {
|
||||
#[ignore = "needs a VA-API GPU: run on the VA-API host"]
|
||||
fn encoders_made_one_after_another_from_one_display_code_every_frame() {
|
||||
let node = std::env::var("RVG_VAAPI_NODE").unwrap_or_else(|_| "/dev/dri/renderD128".into());
|
||||
let display = Display::open(&node, Arc::new(StdRuntime)).expect("a VA display");
|
||||
let display = Display::open(&node, Arc::new(GatedRuntime)).expect("a VA display");
|
||||
let profiles: Vec<encode::Profile> = (encoder_support(&display).into_iter())
|
||||
.map(|s| s.profile)
|
||||
.collect();
|
||||
|
||||
@@ -3,6 +3,13 @@
|
||||
//! registered by [`Runtime::arm_exit`], closes the gate and waits out the steps in progress, at
|
||||
//! most 2 s; a step after that is refused. One gate a process, so a test that closes it runs in
|
||||
//! a child process of its own.
|
||||
//!
|
||||
//! Every test of the hardware opens its display on it, as the host opens its own on its gate:
|
||||
//! the display's call thread and the work kept past its deadline (`super::wait`'s `keep`, whose
|
||||
//! thread lets a kept session go after the count a test waits on drops to 0) call the driver on
|
||||
//! threads of their own, and a test returns while they still may. With no gate the test's
|
||||
//! process then exits beside them: the driver's exit-time destructors, which `vaInitialize`
|
||||
//! registered, run while a thread is still in the driver.
|
||||
|
||||
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -875,9 +875,9 @@ mod tests {
|
||||
#[test]
|
||||
#[ignore = "needs a VA-API GPU: run on the VA-API host"]
|
||||
fn the_check_lends_no_way_a_decoder_shape_comes_out_wrong_through() {
|
||||
use crate::core::runtime::StdRuntime;
|
||||
use crate::vaapi::va::gated::GatedRuntime;
|
||||
let node = std::env::var("RVG_VAAPI_NODE").unwrap_or_else(|_| "/dev/dri/renderD128".into());
|
||||
let display = Display::open(&node, std::sync::Arc::new(StdRuntime)).expect("a display");
|
||||
let display = Display::open(&node, std::sync::Arc::new(GatedRuntime)).expect("a display");
|
||||
let writes = display.import_writes();
|
||||
let mut lent_wrong = Vec::new();
|
||||
for format in FORMATS {
|
||||
@@ -972,10 +972,10 @@ mod tests {
|
||||
use super::super::surface::Rect;
|
||||
use super::super::wait::Deadline;
|
||||
use crate::core::backend::DeviceWrite;
|
||||
use crate::core::runtime::StdRuntime;
|
||||
use crate::vaapi::va::gated::GatedRuntime;
|
||||
|
||||
let node = std::env::var("RVG_VAAPI_NODE").unwrap_or_else(|_| "/dev/dri/renderD128".into());
|
||||
let display = Display::open(&node, Arc::new(StdRuntime)).expect("a display");
|
||||
let display = Display::open(&node, Arc::new(GatedRuntime)).expect("a display");
|
||||
let mut failed = Vec::new();
|
||||
for format in FORMATS {
|
||||
let lent = display.writes_imports(format);
|
||||
|
||||
@@ -465,9 +465,9 @@ fn check_kind(display: &Display, codec: TargetCodec, format: TargetFormat) -> Re
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::codec::encode::{EncoderSettings, InputFrame, Plane, Profile as Encoded};
|
||||
use crate::core::runtime::StdRuntime;
|
||||
use crate::vaapi::va::encoder::VideoEncoder;
|
||||
use crate::vaapi::va::frame::PlaneRows;
|
||||
use crate::vaapi::va::gated::GatedRuntime;
|
||||
|
||||
/// The encoded streams' size: rows of a multiple of 256 bytes.
|
||||
const SIZE: (u32, u32) = (1280, 720);
|
||||
@@ -475,7 +475,7 @@ mod tests {
|
||||
|
||||
fn display() -> Display {
|
||||
let node = std::env::var("RVG_VAAPI_NODE").unwrap_or_else(|_| "/dev/dri/renderD128".into());
|
||||
Display::open(node, StdRuntime::shared()).expect("a VA display")
|
||||
Display::open(node, std::sync::Arc::new(GatedRuntime)).expect("a VA display")
|
||||
}
|
||||
|
||||
/// `PICTURES` pictures of a gradient moving a few samples a picture, by the driver's encoder
|
||||
|
||||
@@ -290,9 +290,9 @@ fn run(display: &Display, stream: &std::path::Path, laid: Option<Laid>, scribble
|
||||
/// same, and the first stream each way refused or came out other at. Prints its answers; asserts
|
||||
/// only that it decoded something.
|
||||
pub(crate) fn probe(node: &str, dirs: &str) {
|
||||
use crate::core::runtime::StdRuntime;
|
||||
use crate::vaapi::va::gated::GatedRuntime;
|
||||
|
||||
let display = Display::open(node, std::sync::Arc::new(StdRuntime)).expect("a display");
|
||||
let display = Display::open(node, std::sync::Arc::new(GatedRuntime)).expect("a display");
|
||||
let mut streams: Vec<std::path::PathBuf> = (dirs.split(':'))
|
||||
.flat_map(|dir| std::fs::read_dir(dir).expect("a streams directory"))
|
||||
.map(|entry| entry.expect("a directory entry").path())
|
||||
|
||||
@@ -15,6 +15,7 @@ use crate::vaapi::va::caps::{self, Config, Context, Entrypoint};
|
||||
use crate::vaapi::va::display::{Display, Error};
|
||||
use crate::vaapi::va::encoder::VideoEncoder;
|
||||
use crate::vaapi::va::frame::Frame;
|
||||
use crate::vaapi::va::gated::GatedRuntime;
|
||||
use crate::vaapi::va::h264::H264Decoder;
|
||||
use crate::vaapi::va::readback::copy;
|
||||
use crate::vaapi::va::surface::{Surface, SurfaceFormat, SurfacePool};
|
||||
@@ -34,7 +35,7 @@ const ENCODE_WAIT: Duration = Duration::from_millis(4);
|
||||
|
||||
pub(super) fn display() -> Display {
|
||||
let node = std::env::var("RVG_VAAPI_NODE").unwrap_or_else(|_| "/dev/dri/renderD128".into());
|
||||
Display::open(node, StdRuntime::shared()).expect("a VA display")
|
||||
Display::open(node, std::sync::Arc::new(GatedRuntime)).expect("a VA display")
|
||||
}
|
||||
|
||||
/// Frame `n` of noise at [`SIZE`], NV12.
|
||||
|
||||
Reference in new issue
Block a user