From 6eb715dac8881917c4476c5c3ced1fd9dbf467b2 Mon Sep 17 00:00:00 2001 From: chrg6 Date: Mon, 9 Nov 2026 05:57:16 -0500 Subject: [PATCH] Let the present thread finish before the held work is walked at a present, which it may be replaying and freeing. Co-Authored-By: Claude Opus 5.5 --- runtime/vk_backend.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runtime/vk_backend.c b/runtime/vk_backend.c index ef7f9978..f5389dfd 100644 --- a/runtime/vk_backend.c +++ b/runtime/vk_backend.c @@ -224,7 +224,10 @@ static int present_held_on(void) { static uint64_t submit_sync(const uint64_t *handles, int n); // The held work that can go on now, in a submission of its own (vk_exec_record syncs it like any other: held_sync). +// The present thread first finishes what it was handed: its empty submission replays held work and frees what it +// replayed (vk_exec_record), which this walk reads. A present ph_flush handed it a moment ago is such a case. static int held_resume(void) { + vk_present_drain(); if (!vk_exec_held() || !vk_exec_held_ready()) return 0; submit_sync(NULL, 0); PH.ran++;