Let a destroyed vsync event give its slot when the vsync list is full, instead of ending the process on the 17th.

gfx_vsync_bind kept every SystemEventType address the game ever passed to GetDisplayVsyncEvent, never dropped one, and
called rt_fatal on the 17th distinct address. A destroyed event also stayed on the list the vsync thread signals 60
times a second. kernel.c now exports kern_system_event_live (mapped guest memory with a nonzero state byte), and with
the list full gfx_vsync_bind gives the first slot whose event is no longer live to the new one, which also takes the
destroyed event off the vsync thread's list; it stays fatal only when all 16 are live. Each new listing logs
"gfx: vsync event ... bound in slot N, M listed", so a long session's log shows how often new addresses come.

Not reproduced before the change: the fresh 0.10.0 session's system event count stayed at 9-10 across its area loads,
and no log here covers returns to the title. tests/vsync_bind_check.py cuts gfx_vsync_bind from gfx_present.c with a
stub liveness check: a 17th event takes the first destroyed slot, an 18th the next, and with 16 live events the 17th
still ends with the fatal. system_event_check now also checks kern_system_event_live. The compile check of every
runtime file passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-13 17:09:19 -05:00
parent 63228e7ca8
commit 0672655c96
5 changed files with 126 additions and 3 deletions

View File

@@ -5,7 +5,7 @@
// number went to an unrelated event or the state byte reads nonzero again; a host thread signalling
// while a guest thread destroys and binds the event again never ends the process; with the table full,
// a new bind takes a destroyed guest-memory entry and keeps the entries in host memory, which a host
// thread then still signals
// thread then still signals; kern_system_event_live tells live guest events from destroyed ones
// full every entry live: the next bind ends with "table full" (the script checks the exit code and text)
#include "kernel.c"
@@ -111,7 +111,9 @@ static void stale_and_reuse(void) {
CHECK(signaled(wh) == 1, "a live bound event is signalled");
kern_clear_system_event(ev_of(ev));
CHECK(signaled(wh) == 0, "a live bound event is cleared");
CHECK(kern_system_event_live(ev_of(ev)), "kern_system_event_live: a bound event in guest memory is live");
destroy(ev);
CHECK(!kern_system_event_live(ev_of(ev)), "kern_system_event_live: a destroyed event is not");
kern_signal_system_event(ev_of(ev)); // state byte 0: skipped before the kernel lock
// The byte reads nonzero again with the handles closed (the memory reused, or the SDK made the event again
// without the binder): the signal must neither end the process nor reach anything.