✅ Script an answer behind an owed CB_SCHEDULED
The doorbell fuzz target failed where no buffer of its cases was answered behind one of its queue that owed its CB_SCHEDULED. It answered about 3.4 such buffers a run of its default 256 cases, so the guard rested on chance. Under RGFX_FUZZ_SEED 1 to 300, 11 runs answered none (m3-max-81328). Ahead of its drawn cases, the target now runs one scripted case, at any seed, in both of its runs. Two buffers of queue 1 are each an empty blit pass. The first asks for no CB_SUBMITTED, so its CB_SCHEDULED waits for the platform's take, which the platform holds from its commit. The second asks, and is offered to the answer while the first owes its record. The target fails unless the second buffer is answered behind the owed record and the answer offers no CB_SCHEDULED of its own. Both runs must give the platform the same calls and the guest the same records. The case counts among the answers behind an owed record, so that guard holds at any seed. Tests (homelab-um870-1, fake platform; counts measured): - m3-max-81535: cargo fmt and clippy (host and Windows) are clean. The 999 tests of graphics::decode and graphics::tests pass, and so do the fuzz's six targets. - The doorbell target's answers line is the parent's, with 3 answers behind an owed record in place of 2. The other targets' counts are the same. - The scripted case alone passes under RGFX_FUZZ_SEED 0 to 20. - Red: with the answer's owed check removed, the scripted case fails, its CB_SCHEDULED records out of order for the guest (37 before 36). - Red: without the platform's hold, the scripted case fails, the line owing nothing at the second buffer's offer. - m3-max-81543: under RGFX_FUZZ_SEED 1 to 300 the target passes at every seed, each with 1 or more answers behind an owed record. At each seed but 72, its answers line is m3-max-81328's with one more such answer. Seed 72 ended in a panic there, in a heap's buffer, which an earlier commit fixes.
This commit is contained in:
1 parent
80169b88e7
commit
94e64a69c5
1 file changed
+70
-1
@@ -3880,7 +3880,8 @@ type Run = (Vec<&'static str>, Vec<String>, Vec<(&'static str, u64)>);
|
||||
/// holds the platform's take as well, as a platform may take a buffer's work after its commit. The
|
||||
/// held work is taken at one step in four, and at the case's end, then completed. No buffer is
|
||||
/// answered behind one of its queue that waits and is not yet scheduled, and an answer behind a
|
||||
/// buffer of its queue that owes its `CB_SCHEDULED` posts no `CB_SCHEDULED` of its own.
|
||||
/// buffer of its queue that owes its `CB_SCHEDULED` posts no `CB_SCHEDULED` of its own. One case,
|
||||
/// scripted ahead of the drawn ones, makes such an answer at any seed.
|
||||
///
|
||||
/// One buffer in four is of queue [`QUEUE_2`] ([`doorbell_setup`]), each queue's at seqnos rising
|
||||
/// from 1, and a well-formed pass ([`seeded_stream`]) led by an empty `SURFACE_ORDER`, so that it
|
||||
@@ -3910,6 +3911,74 @@ fn an_answer_at_the_doorbell_keeps_the_order_of_a_take() {
|
||||
// `SURFACE_ORDER` and a `COMMIT_ORDER`.
|
||||
let (mut owing_fill, mut naming_unfinished) = (0u64, 0u64);
|
||||
let mut answered_framing = [0u64; 3];
|
||||
// One case scripted, at any seed: two buffers of queue 1, each an empty blit pass. The first
|
||||
// asks for no `CB_SUBMITTED`, so its `CB_SCHEDULED` waits for the platform's take, which the
|
||||
// platform holds from its commit; the second asks, and is offered while the first owes its
|
||||
// record. It is answered, posting its `CB_SUBMITTED` and no `CB_SCHEDULED`, and the platform
|
||||
// and the guest see what they see when it is taken.
|
||||
let scripted = |answering: bool| -> (Run, Option<(bool, bool, bool)>) {
|
||||
let (p, mut dec, seen) = setup();
|
||||
doorbell_setup(&p, &mut dec);
|
||||
p.world().set_auto_complete(Some(CompleteOn::Caller));
|
||||
let device = p.device();
|
||||
let from = p.call_log().mark();
|
||||
let mut outcomes = Vec::new();
|
||||
// The second buffer's offer: whether the line owed, whether it was answered, and whether
|
||||
// the answer offered a `CB_SCHEDULED`.
|
||||
let mut offer = None;
|
||||
let mut ops = framed(RGFX_OP_ENCODER_BEGIN_BLIT, &[]);
|
||||
ops.extend(framed(RGFX_OP_ENCODER_END, &[]));
|
||||
for seqno in [1, 2] {
|
||||
if seqno == 2 {
|
||||
ops.extend(framed(RGFX_OP_SUBMITTED, &[]));
|
||||
}
|
||||
let m = command_buffer_as(1, seqno, OBJECTS + seqno, ops.len() as u64, &ops);
|
||||
if seqno == 1 {
|
||||
p.world().hold_submissions();
|
||||
} else if answering {
|
||||
let owed = dec.queue_counts(1).is_some_and(|c| c.line.owes());
|
||||
let posted = Arc::clone(&seen);
|
||||
let scheduled_offered = std::cell::Cell::new(false);
|
||||
let offered_at = &scheduled_offered;
|
||||
let yes = dec
|
||||
.decoders()
|
||||
.answer_at_doorbell(CONTEXT, &m, move |bytes| {
|
||||
let m = RgfxCbScheduled::read_from_bytes(bytes).unwrap();
|
||||
let scheduled = m.header.r#type == RGFX_EVT_CB_SCHEDULED;
|
||||
offered_at.set(offered_at.get() || scheduled);
|
||||
let kind = if scheduled { "scheduled" } else { "submitted" };
|
||||
posted.lock().push((kind, m.cb_obj_id));
|
||||
true
|
||||
});
|
||||
offer = Some((owed, yes, scheduled_offered.get()));
|
||||
}
|
||||
let begun = refusing(|| dec.begin_taken(&device, &m, Some(1), false));
|
||||
let outcome = match begun {
|
||||
Ok(Ok(begun)) => refusing(|| dec.finish_command_buffer(&device, &m, begun)),
|
||||
Ok(Err(e)) => Ok(Err(e)),
|
||||
Err(raise) => Err(raise),
|
||||
};
|
||||
dec.end_message();
|
||||
outcomes.push(format!("{outcome:?}"));
|
||||
}
|
||||
p.world().release_submissions();
|
||||
p.world().complete_all(CompleteOn::Caller);
|
||||
let seen = seen.lock().clone();
|
||||
((p.call_log().sels_since(from), outcomes, seen), offer)
|
||||
};
|
||||
let (taken, _) = scripted(false);
|
||||
let (answered_first, offer) = scripted(true);
|
||||
assert_eq!(
|
||||
taken, answered_first,
|
||||
"the scripted case: the answer changed what the platform or the guest sees"
|
||||
);
|
||||
assert_eq!(
|
||||
offer,
|
||||
Some((true, true, false)),
|
||||
"the scripted case: the second buffer's offer (the line owing, answered, a CB_SCHEDULED \
|
||||
offered) is not the one behind the first's owed CB_SCHEDULED"
|
||||
);
|
||||
behind_owed += 1;
|
||||
for case in cases.clone() {
|
||||
let case_seed = mix(seed ^ case);
|
||||
let mut run_case = |answering: bool| -> Run {
|
||||
|
||||
Reference in new issue
Block a user