Skip to content

viacuda: fix livelock caused by autopoll clobbering in-progress transactions#168

Merged
dingusdev merged 1 commit intodingusdev:masterfrom
jarz:viacuda-livelock
Feb 21, 2026
Merged

viacuda: fix livelock caused by autopoll clobbering in-progress transactions#168
dingusdev merged 1 commit intodingusdev:masterfrom
jarz:viacuda-livelock

Conversation

@jarz
Copy link
Contributor

@jarz jarz commented Feb 21, 2026

autopoll_handler() is called on every SDL event loop iteration. When a poll returned data while a Cuda transaction was already in progress (old_tip=0 or treq=0), the handler would log a warning but proceed anyway — overwriting out_buf, asserting TREQ, and scheduling a new SR interrupt. This prevented the guest from ever completing the previous transaction, causing a livelock where the emulated Mac appeared frozen (cursor still moves since mouse events are handled separately).

The same issue affected one-second time packets sent during the one_sec_mode path.

Additionally, AdbDevice::poll() calls get_register_0() which destructively consumes keyboard events and mouse deltas. Even if we had returned after the warning, the ADB data would already be lost.

Fix by moving the busy check before the poll() call so that when a transaction is in progress, the handler returns immediately without polling ADB devices. Events remain queued in ADB device buffers and are picked up on the next cycle when the bus is idle.

@dingusdev dingusdev merged commit 8309ce0 into dingusdev:master Feb 21, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants