acphal: hal_pop Win32 BOOL ABI mismatch, stale MSG_DISCONNECTED on reconnect, and +125 ppm frame-clock drift #329
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#329
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@mastrr9 on GitHub · 2026-11-23 23:29 UTC · original
Static audit of
crates/xcl/src/hle/acphal.rsonmain(85bdf21) found three correctness bugs inacphal:hal_popreturns a 1-byte Rustboolacross Windowsextern "system"ABI (acphal.rs:434-445)unsafe extern "system" fn hal_pop(h: *mut Hal, m: *mut Message) -> boolonly guarantees the low byte (AL) is set to0/1, leaving the upper 24 bits ofEAXundefined.BOOLinspect fullEAX, sofalsecan be observed as non-zeroTRUEand cause a caller to process a stale/uninitializedMessageor spin.booltou32(returning1/0).Channel::connect()leaves staleMSG_DISCONNECTEDqueued (acphal.rs:354-362)disconnect()pushesMSG_DISCONNECTEDontoself.messages, butconnect()does not clearself.messages. A title that disconnects and later reconnects immediately pops a staleMSG_DISCONNECTEDon the fresh connection.self.messages.clear()inChannel::connect().Audio frame clock drifts
+125 ppm(acphal.rs:39)const FRAME: Duration = Duration::from_micros(2667);vs exact128 / 48_000s (2666.666... µs) accumulates+0.333 µsper frame (+125 ppm, ~450 ms/hour slow relative to 48 kHz audio).connect_timeand compute framekdeadline asconnect_time + Duration::from_nanos(k * 128_000_000_000 / 48_000)(or integer nanosecond accumulator) so there is zero long-term drift.Not tested: on Windows (static code audit + clean-room timing arithmetic check on macOS; no game files).
AI use: Audited with Antigravity (Gemini 4 Neon) and Claude Sonnet 5.5 (static code review only).