|
Download docs/research/EVENT_QUEUES.md from nmarshall/urt-rs: direct link, hf CLI and curl.
- Browser
- Download file 8.42 kB
-
https://huggingface.co/nmarshall/urt-rs/resolve/main/docs/research/EVENT_QUEUES.md
- Command line
-
hf download hf://nmarshall/urt-rs/docs/research/EVENT_QUEUES.md
-
curl -L -o EVENT_QUEUES.md https://huggingface.co/nmarshall/urt-rs/resolve/main/docs/research/EVENT_QUEUES.md
8.42 kB
| # Native client address types, event rings and journals | |
| Static pass, 2026-10-11. Reproduce with `python3 scripts/analyze_event_queues.py`; check with `python3 scripts/test_event_queues.py`. [Generated evidence](event-queues.json) contains sixteen Linux ELF64 instruction graphs, queue symbol addresses/sizes, file-backed address-format strings, focused caller windows and 108 literal field references per engine. Original/disassembly hashes are checked before collection. No original game process, native callee or complete QVM executes in this pass. | |
| ## EVT-001: the counted pause field is an address type | |
| The earlier [pause report](FRAME_TIMING.md) intentionally left field `client + 0x24ee4` unnamed. The new evidence connects it to the native network address through independent paths: | |
| - `SV_DirectConnect` forms `client + 0x24edc` as the second argument of `Netchan_Setup`. | |
| - `Netchan_Setup` stores the incoming address type at channel offset 8. Thus `0x24edc + 8 = 0x24ee4`. | |
| - Address bytes are written at channel offsets 12–15, and a 16-bit port at offset 16. At the client level the address starts at `0x24ee4`, address bytes at `0x24ee8`, and port at `0x24eec`. | |
| - `SV_UserinfoChanged` loads eight bytes from `0x24ee4` and four from `0x24eec` into the native address arguments used by `NET_IsLocalAddress`, `NET_AdrToString` and LAN checks. Packet matching similarly passes that region to address comparison. | |
| - `SV_BotAllocateClient` writes zero at `0x24ee4`. `NET_AdrToString`'s type-zero branch uses the file-backed string `bot`; type two uses `loopback`, and type four uses `%i.%i.%i.%i:%hu`. `NET_IsLocalAddress` tests type two. | |
| - `SV_DropClient`'s zero-type path reaches `SV_BotFreeClient` after its disconnect callback and command path. | |
| These paths establish **bot = 0, loopback = 2, IPv4-format path = 4** for these binaries. They do not recover every address enum member, prove IPv6 support, or establish that every unknown value is rejected. Do not copy a different engine revision’s enum into the rewrite without checking the supplied fork. | |
| Consequently the pause gate counts state words unsigned greater than one with a **nonzero address type**; zero-type bots are excluded. It is more precise to say nonbot clients than human players: connection state and address validity still constrain the result. With at most one counted client the pause helper returns one and selects `sv_paused=1`; with more it returns zero and clears that cvar if needed. The `cl_paused=0` early return still leaves prior `sv_paused` state untouched in this helper. | |
| The report's 108 direct displacement references in each engine include allocation, drop, connection, pause, status, packet and send paths. This is a literal-offset index, not a complete inventory of aliases, computed pointers or writes. Full client/netchannel layout, reachable lifecycle states, game-mode timeouts and original-runtime pause scenarios remain open under RE-235. | |
| ## EVT-002: two rings and overflow ownership | |
| | Ring | Storage | Record size | Index selection | Observed full condition | | |
| | --- | --- | --- | --- | --- | | |
| | Platform `eventQue` | 8192 bytes / 256 records | 32 bytes | Low eight bits of head | Signed 32-bit head-minus-tail greater than 255 | | |
| | Common `com_pushedEvents` | 32768 bytes / 1024 records | 32 bytes | Head masked with 0x3ff | Signed 32-bit head-minus-tail greater than 1023 | | |
| The storage sizes come from retained ELF symbols, independently of the masks and overflow comparisons in instructions. `Sys_QueEvent` receives timestamp, type, two values, payload length and payload pointer. It stores those fields at offsets 0, 4, 8, 12, 16 and 24 respectively. The four bytes at offset 20 are alignment space and are not assigned by this function. A zero supplied timestamp is replaced by `Sys_Milliseconds()`; a nonzero one is retained. | |
| At normal full capacity, both push functions select the head slot, which coincides with the oldest retained slot. On overflow they free that slot’s nonnull payload through `Z_Free`, advance tail, replace the event, and advance head. The producer copies/transfers the incoming payload pointer rather than cloning its bytes. Consumer/event-loop cleanup was captured in the earlier timing report. These observations imply ownership requirements for a Rust queue, but do not establish that all producers obey them or that arbitrary malformed pointers are safe. | |
| `Sys_QueEvent` prints on each observed overflow path. `Com_PushEvent` uses a retained `printedWarning` flag: the first full insertion prints and sets it; subsequent full insertions suppress the warning. An insertion when not full clears the flag, enabling another warning on a later overflow. `Com_InitPushEvent` zeroes the full 32768-byte storage and resets head/tail; its body does not explicitly reset the warning flag. Do not interpret initialization as safe cleanup of previously owned live payloads without examining call sites. | |
| The graph collector retains local branch edges and possible call continuation; it does not execute queue transitions. Full signed counter wrap, pathological head/tail differences, producer concurrency, allocation failures, reset-time ownership and real burst behavior need fixtures. The capacity statements concern normal queue invariants, rather than proving behavior for every 32-bit counter state. | |
| ## EVT-003: clock queries preserve queued events; journal inspection | |
| `Com_Milliseconds` calls `Com_GetRealEvent` repeatedly until a type-zero event arrives, then returns its timestamp. For each nonzero event it inserts the complete 32-byte record into the common pushed ring. The compiler inlines the same overflow, payload-free and warning-flag paths seen in `Com_PushEvent`; it does not call that function or directly call `Sys_Milliseconds` in the recovered body. The common warning flag is shared by these paths. | |
| This clock service therefore has queue and ownership side effects. A Rust replacement that always reads a host clock would omit event preservation and could lose journal replay timing. The returned event time can come from a journal rather than a live host sample. Full caller expectations and event-loop reentrancy still need investigation. | |
| The earlier `Com_GetRealEvent` graph reads/writes a raw 32-byte event header, then the indicated payload. The new inspector uses the observed **little-endian Linux ELF64** layout: | |
| | Offset | Bytes | Interpretation | | |
| | --- | --- | --- | | |
| | 0 | 4 | Signed timestamp | | |
| | 4 | 4 | Event type word | | |
| | 8 | 4 | First value | | |
| | 12 | 4 | Second value | | |
| | 16 | 4 | Signed payload length | | |
| | 20 | 4 | Preserved alignment bytes | | |
| | 24 | 8 | Historical pointer value | | |
| | 32 | Payload length | Payload bytes; next header follows immediately | | |
| For a future captured journal, use: | |
| ```sh | |
| python3 scripts/analyze_event_queues.py --journal .cache/research/capture.journal --output docs/research/capture-journal.json | |
| ``` | |
| No captured original journal is present or claimed in this pass. The inspector retains signed words, padding, historical pointer values, source hash, record offsets and payload hashes, and never dereferences a stored pointer. Synthetic fixtures exercise mixed records and payload boundaries. It rejects truncated headers/payloads, negative lengths and configured size/count limits. Those stricter bounds are **inspector policy**, not proof that the original parser rejects the same inputs. Types are preserved even when unknown. A zero-length payload consumes no bytes regardless of historical pointer value. | |
| Raw pointer width and alignment make it unsafe to assume this journal representation is portable to ELF32, Windows or macOS. Recover those layouts separately and define a portable versioned research/replay format before using captures in the replacement. This journal is also distinct from network demo formats; do not apply this inspector to demos based on extension alone. | |
| ## Completed slices and remaining work | |
| RE-237–239 record the static address-type chain, queue storage/overflow paths, clock-query side effects and bounded journal inspector. RE-235/236 remain open for runtime validation and broader semantics. RE-240 adds complete producer/consumer/reset ownership, counter-wrap behavior and cross-platform journal-layout recovery. The scripts/tests validate collection, storage bounds and synthetic journal parsing; they do not constitute original-runtime queue or pause conformance tests. | |