fix(os): refuse a multi-wait link or move whose holder array cannot grow #2445

Open
dazemc wants to merge 2 commits from dazemc/Longshot:fix/os-multiwait-holder-alloc into main
Contributor

Summary

mw_link and mw_move_all grow a multi-wait's holder array with realloc. On failure the old code kept going and wrote through the stale or null result: a failed LINK could link a holder it could not store, and a failed MOVEALL could lose the holders it moved. This change refuses the operation instead — nothing is linked or moved, the list stays as it was, and the refusal is logged once — and covers the failure paths with fail_next_realloc cases.

This is split out of #2141 (#2141) so the timer-period fix there merges without this change. That head no longer contains the holder-array work; this change does not contain the timer fix.

Head

Branch fix/os-multiwait-holder-alloc, head a86c8e4644d55a18e7c7d7eedd19d51061b4e3d9, based on be663a08a30fa953420104d3cef6877bed6674a2 (current main). Diff against main: 2 files changed, 54 insertions(+), 9 deletions(-).

What moved here, case by case

Between 12ed3a32 (the pre-split head of #2141) and 91add521 (#2141 now), tests/test_multiwait_wake.py lost 29 lines. Each is accounted for:

  • 2 lines, fixture support — static int logs; and hos_log(...), the counter the refusal messages use; present here.
  • 26 lines, one case block — four scenarios: a failed fresh LINK; a link after that failure; MOVEALL(mw, mw) onto itself; a failed MOVEALL(other, mw). Eight assertions, at tests/test_multiwait_wake.py:211-227; fail_next_realloc set at lines 209, 215 and 221 (cleared at 225), its fixture at 45 and 47.
  • 1 line, a PASS: summary string.

All eight assertions exist here and are absent from 91add521. No case exists at neither branch, so this is a move, not a loss.

What stayed in #2141

The periodic-timer consumption and the two-thread concurrent-wait case remain in 91add521 and are absent here.

Rebase status (2026-11-25, current): a86c8e464 → 80f9a3713 onto main @ 8f7300756701b7c9a278e576bb075ac20e622a32. Stable patch-id 9795739d3333d65f83e7abe01d6647e4ea71f334 is unchanged and main's old-base→new-main file intersection with this PR is empty. The evidence already named below (suite, platform, in-game and measurement, as applicable) therefore still stands at the historical heads that produced it. Earlier rebase notes are history; where they say "this head", they mean the evidence commit named beside that run, not 80f9a3713.

Testing

Rebase (2026-11-25). Rebased onto origin/main be663a08a30fa953420104d3cef6877bed6674a2. Old head 01324116f6ce26be10bd196fa7958e85744bc33d → new head a86c8e4644d55a18e7c7d7eedd19d51061b4e3d9. git diff -U0 8aa5ab87..01324116 and git diff -U0 be663a08a3..a86c8e46 hold the identical changed-line set (60 added/removed lines, 0 differing), so the rebase changed nothing this PR writes. Main's new commits touch neither host/nn_os_sync.c nor tests/test_multiwait_wake.py (the intersection is empty), so the in-game, Windows and suite results below still describe this PR's code; they were taken at 01324116 and this rebase is the only change since. No suite re-run is owed. Note for the merge: #2445 and #2141 both edit tests/test_multiwait_wake.py at different lines, and the pair conflicts there even though each is clean against main; the second to merge needs that one-file resolution.

Tested: Tested in game at 01324116 (v3.2.0-14), windowed at 948x1036 on HDMI-A-2 (Hyprland, output 3840x2160), 60.1 fps: Kokiri Forest (child), ~42 s of play after warm-up (3,126 frames between the play-start and play-end shots, 600 of them the warm-up), age child, life 12/12, no crash, clean quit (exit 0). Linux/Hyprland (Wayland), RTX 4070 Ti, driver 620.73.04.

The harness prints 120 s; the measured play was 42 s — the label counts loop iterations, not frames. The earlier --force blessing is superseded: the claim now rests on a real in-game result, not a blessed one.

The fix-test, both ways. The test file as committed here, built against main's host/nn_os_sync.c (8aa5ab87), stops in the new failed-realloc case: the fixture prints nothing and dies with rc=-11 (SIGSEGV) in both modes — main writes through the NULL realloc returned — and the test exits 1 at FAIL: targeted. At this head the same file prints targeted: ok, all: ok and PASS: … allocation failure preserves wakes, links and moves nothing, and says so once, exit 0. Control: main's own older test file run at main passes, so the failure is the new case against main's code, not a broken fixture. Both were re-run on 2026-11-24 and reproduced their logs byte for byte.

mise run test at this head. The full suite ran at 01324116f6ce26be10bd196fa7958e85744bc33d on 2026-11-24: header 961 checks, 18 skipped, 5 at once (linux), summary 942 passed, 19 failed, 18 skipped in 403 s (linux, 5 at once), JUnit tests="979" failures="19" skipped="18" time="403.485" — 961 ran + 18 skipped = 979, and 942 + 19 = 961. Every one of the 19 failing ids is a CORE id of the suite rule's AMENDMENT 1 and carries that id's exception class; no id outside CORE∪FLAKY failed; the 18 skips are the baseline's, with no head-declared addition. Verdict under AMENDMENT 1: pass (counts are not compared). Log prrefresh-logs/suite-2445-01324116.log, sha256 1856864fef9c3cc87ce5e1f1d55b62a2987aa1dd456f1fc86f58f32d3ce20410; JUnit prrefresh-logs/suite-2445-01324116.xml, sha256 915c559947fcd2e0732fdbbdccf702fc01297d9618fa31570a043940522beb60; comparison witness prrefresh-logs/suite-2445-01324116.compare.txt, beside .head (the PR head), .start, .end and .exit (1).

Tested on Windows (llvm-mingw). At 01324116 on a Windows 11 x86-64 box (Acer Nitro AN515-57, i5-11400H, llvm-mingw 20261104 UCRT), nx2\build.py --standalone with RX_VK_ONLY=1 compiled 268 renderer objects of this head and linked them: compiled in 190 s, 0 failed, link 1 s, 6 jobs, lifted code … (0 files) in the log, so no game data was read. Result: C:\Users\daze\longshot-2445\work\sa\build\longshot_vk.dll, 17,704,960 bytes, sha256 3e8b0af5f540d49846bc0e44e2e28123617d4b662e0ac1c615834a25b8b9b858, PE32+ (0x20B) IMAGE_FILE_MACHINE_AMD64 / IMAGE_SUBSYSTEM_WINDOWS_GUI, exporting mkwvk_init, mkwvk_close_asked, mkwvk_crash_close and mkwvk_crash_page; llvm-strings finds 01324116 (source 58358c6a) in it. The checkout's git rev-parse HEAD was 01324116f6ce26be10bd196fa7958e85744bc33d (.head beside the log); build log build-01324116.log, sha256 70cc3a79c5ce56e35bde72b62478c3c65c89be94f7ca1583e628626eff0679e2. The file this PR changes compiles as well: host/nn_os_sync.c → host_nn_os_sync.obj, 136,318 bytes, sha256 fd466fdbd17b1386139b0936b4f85d8be5560eae1e7723568c4186d618456d0c, COFF machine 0x8664, with nx2/build.py's own host flags. That was the renderer DLL link, not the single-object compile the earlier tree had; the whole pack then ran at this head on the same box, windowed: longshot.exe 577,531,904 bytes, sha256 ccb5b8c7c7fa493d875f1dc6f8676e1a26839fc7181b5a828c393fa381e91f48, on the NVIDIA GeForce GTX 1650, driver 610.62; the LOW MEMORY dialog was dismissed with WM_CLOSE before play. The game window was pid 5280, handle 1049456, title Longshot, rect 77,77,1371,835 (1294x758), visible=True at the in-play, mid-play and end-play checks; play ran from frame 3016 at 36.0 fps to frame 5882 at 46.1 fps, both samples in KokiriForest_Child, 2,866 frames over 64 s of wall time, then exit_code 0 / stop exit, with 0 vk: no window and 0 could not start lines. Log runs\win-2445\log.txt (783,674 bytes, sha256 60af2ac0e0ab6bd63b6350c8b0d83a884bec1d60c4d96a0897ee45e4ccadee6c) and smoke log smoke-01324116.log (25,806 bytes, sha256 9036f86f924a1b07f3438c9132e177ae221c37d960d3ed1ddbaa5000ac15ab5d); the screenshots and the game data stayed on that box, since nothing left it.

Still to test:

  • Done — the Windows (llvm-mingw) link at this head (Tested, by hand).

Measurements

Verdict: no in-game before/after is claimed — main was not run in game for this change — so the measurement is the test: it fails on main's source, in the case the fix adds, and passes at this head. The windowed in-game run at this head is the evidence that the change plays: 60.1 fps, exit_code: 0.

The test, both ways (python3 -I -B tests/test_multiwait_wake.py, Linux on this PC, clang++, no game and no GPU):

Before: main @ 8aa5ab87 After: this PR @ 01324116
tests/test_multiwait_wake.py, the head's file against each source FAIL: targeted: empty, FAIL: targeted, fixture rc=-11 (SIGSEGV) in both modes, exit 1 PASS: targeted: ok, all: ok, exit 0
  • ~/.local/share/longshot-dev/prready-2026-11-24/mw-main-headtest.log — the whole test on main's source: targeted: prints nothing, then FAIL: targeted, exit 1. sha256 9ad0e640e254c14fe64d0186bbe7c2fa5daeaf3c3ce0d380a8cc00dd514b2ac9
  • ~/.local/share/longshot-dev/prready-2026-11-24/mw-main-rc.log — the same fixture's child return code: targeted: rc=-11 (SIGSEGV), all: rc=-11 (SIGSEGV). sha256 8ed5fcb7fe9990cccb359f570489cc580a8b1078d40169134eb9ebcb12e5fbab
  • ~/.local/share/longshot-dev/prready-2026-11-24/mw-01324116.log — at this head: targeted: ok, all: ok, exit 0. sha256 61cda68ddd03349b38541bdab8dd2ba11b2c07c2ad9ea66a784baaf120b0e163
  • Control, ~/.local/share/longshot-dev/prready-2026-11-24/mw-main.log — main's own test file at main passes. sha256 9921bac836774e1821456ec7712aa2b46f356b0b254da6415846956da60596c8

The windowed in-game run at this head. 01324116 (v3.2.0-14-g01324116f, source 58358c6a), Kokiri Forest (KokiriForest_Child, child), on the 3840x2160 screen and windowed — the log carries sdl: SDL3 and a 1896x2072 swapchain, and no vk: no window line. 60.1 fps at the play-end sample; 3,126 frames between the play-start and play-end shots (present 1819 → 4945), 600 of them the 10 s warm-up, so (3,126 − 600) / 60 = 42.1 s of measured play; exit_code: 0. The window is 1896x2072, the 2× buffer of a 948x1036 logical window; the logical size and HDMI-A-2 are reported, unsubstantiated here (no hyprctl clients -j capture was kept). Driver 620.73.04. Queue ticket 1082824 — reported, unsubstantiated: the queue directory now holds only .lock.

Artefacts: ~/.local/share/longshot-dev/smoke-2026-11-24/b-queue-output.log (line 4 and line 10 window 1896x2072; line 10 fps 60.1; line 7 == warm-up 10 s ==; line 52 "exit_code": 0; line 144 state: finished exit: 0), sha256 5ab4b16c934dc1840c93bc2647f5a536534700e63c7bcb6c54998c8477db2f63; ~/.local/share/longshot-dev/runs/control/b-holder-alloc-windowed-20261124/log.txt (line 61 vk: driver: NVIDIA 620.73.04; line 73 screen 3840x2160 at 165 Hz; line 101 swapchain 1896x2072; line 1701 present 1819 at the play-start shot; line 2603 3720 presents, 60.1 fps; line 3223 present 4945 at the play-end shot; the log has no vk: no window line), sha256 29294f476e2497e40bc4861e5774b4511e9ba9a726954072a5707990adb228f6; ~/.local/share/longshot-dev/runs/control/b-holder-alloc-windowed-20261124/manifest.json (present 1819 → 4945, exit_code 0), sha256 2d1613e5a525d8cdc1efb523c532be0fa032226996421bf45594b4db52a63926.

Risks

An allocation that fails now costs a holder, not the process. Both calls are void, so no error reaches the game: a refused LinkMultiWaitHolder leaves the holder out of that multi-wait, and a refused MoveAllMultiWaitHolder leaves every holder in the source list — the list unchanged, as the test asserts. The refusal is logged once per process, so it is visible in the log rather than silent. On a machine under enough memory pressure the symptom becomes a wait that never completes instead of a write through NULL — the deliberate trade, and why the log line matters.

Holder-array growth is now a hard error. There is no retry and no fallback: when realloc fails the operation is refused whole. That is what the fix is for, but nothing masks a genuine allocation failure any more.

MoveAllMultiWaitHolder(mw, mw) is now a no-op. It used to append a list to itself until growth failed and the write through NULL followed. No caller is known to rely on the old behaviour; one that did would now move nothing.

Blast radius. host/nn_os_sync.c alone, plus its test: the link, unlink, unlink-all and move-all entry points of nn::os, reached by any game that waits on several objects at once. In normal play nothing observable changes: no switch, no file format, no save, no longshot_options.ini key, no cache; the refusal line is the only new output, and only after a failed realloc. A revert is the whole rollback.

Not covered. The Windows path of realloc and hos_log is untested (the Windows build is parked), and the test models the holder arrays and the wake counting — not threads, timing or the GPU. The in-game run exercises the path that allocates normally; the refusal path itself rests on the test alone.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit. — Rebased head 80f9a3713 is directly on main @ 8f7300756701b7c9a278e576bb075ac20e622a32; the preserved diff is the single topic described in Summary.
  • Tested on my own PC, in the game for a change the game runs. 01324116 in game: kokiri-start repo save → Kokiri Forest (KokiriForest_Child, child), ~42 s measured play after warm-up, exit 0, no crash.
  • mise run test passes. suite-2445-01324116 at 01324116: 942 passed, 19 failed, 18 skipped in 403 s (linux, 5 at once); all 19 failures are CORE ids of the suite rule's AMENDMENT 1 with matching exception classes, 0 ids outside CORE∪FLAKY, the 18 skips are the baseline's. Log, JUnit and witness with their sha256 in Testing.
  • Measured against main, or Measurements says why there is nothing to measure. A fix's measurement is its test output on main and here; both ran — main fails (targeted: empty, rc=-11, exit 1), this head passes (targeted: ok, all: ok, exit 0) — and Measurements holds them with their logs' sha256.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible. — git diff --name-status 8aa5ab87..01324116 lists only host/nn_os_sync.c and tests/test_multiwait_wake.py.

When it applies

  • A fix: a game-free test that fails on main and passes here. tests/test_multiwait_wake.py at this head, built against main's host/nn_os_sync.c, dies in the new failed-realloc case (rc=-11, SIGSEGV, exit 1); at this head it prints targeted: ok, all: ok, exit 0. Logs and sha256 in Measurements.
  • A check under tests/ that reads changed source is updated, not weakened. — tests/test_multiwait_wake.py extracts host/nn_os_sync.c, and the diff adds the case block and assertions without removing any.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. Windows: linked at 01324116, not a single-object compile — nx2\build.py --standalone with RX_VK_ONLY=1 compiled 268 renderer objects and linked longshot_vk.dll on a Windows 11 x86-64 box (compiled in 190 s, 0 failed, link 1 s) from a checkout whose git rev-parse HEAD is 01324116f6ce…: C:\Users\daze\longshot-2445\work\sa\build\longshot_vk.dll, 17,704,960 bytes, sha256 3e8b0af5f540d49846bc0e44e2e28123617d4b662e0ac1c615834a25b8b9b858, PE32+ IMAGE_FILE_MACHINE_AMD64 / IMAGE_SUBSYSTEM_WINDOWS_GUI, exports mkwvk_init, mkwvk_close_asked, mkwvk_crash_close, mkwvk_crash_page, and the DLL carries 01324116 (source 58358c6a). The changed file compiles too: host/nn_os_sync.c → 136,318-byte COFF object host_nn_os_sync.obj (machine 0x8664, sha256 fd466fdb…). Linux: unchanged by this run. Run: longshot.exe with the whole pack at this head, windowed on the NVIDIA GeForce GTX 1650 (driver 610.62) after the LOW MEMORY dialog was dismissed with WM_CLOSE: 577,531,904 bytes, sha256 ccb5b8c7c7fa493d875f1dc6f8676e1a26839fc7181b5a828c393fa381e91f48, window handle 1049456 (pid 5280, rect 77,77,1371,835, 1294x758, visible=True), play ending at 46.1 fps after 2,866 frames in 64 s in KokiriForest_Child, exit_code 0; runs\win-2445\log.txt and smoke-01324116.log on that box. The screenshots and game data stayed there.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers. — 01324116 carries Assisted-by: opencode (DeepSeek V4.1 Flash).

Ready to merge

  • Everything in Still to test has run, its results in Tested. — Merge gate: outstanding items remain in Still to test or are confirmed during review; this update does not tick it.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). — Merge gate: platform coverage is settled during review; this update does not claim new hardware coverage.
  • Approved in review, every comment answered. — Awaiting reviewer approval and resolution of any review comments.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold. — Awaiting CI on the current head; this update does not claim a CI run.
## Summary `mw_link` and `mw_move_all` grow a multi-wait's holder array with `realloc`. On failure the old code kept going and wrote through the stale or null result: a failed `LINK` could link a holder it could not store, and a failed `MOVEALL` could lose the holders it moved. This change refuses the operation instead — nothing is linked or moved, the list stays as it was, and the refusal is logged once — and covers the failure paths with `fail_next_realloc` cases. This is split out of #2141 (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2141) so the timer-period fix there merges without this change. That head no longer contains the holder-array work; this change does not contain the timer fix. ## Head Branch `fix/os-multiwait-holder-alloc`, head `a86c8e4644d55a18e7c7d7eedd19d51061b4e3d9`, based on `be663a08a30fa953420104d3cef6877bed6674a2` (current `main`). Diff against `main`: 2 files changed, 54 insertions(+), 9 deletions(-). ## What moved here, case by case Between `12ed3a32` (the pre-split head of #2141) and `91add521` (#2141 now), `tests/test_multiwait_wake.py` lost 29 lines. Each is accounted for: - **2 lines, fixture support** — `static int logs;` and `hos_log(...)`, the counter the refusal messages use; present here. - **26 lines, one case block** — four scenarios: a failed fresh `LINK`; a link after that failure; `MOVEALL(mw, mw)` onto itself; a failed `MOVEALL(other, mw)`. Eight assertions, at `tests/test_multiwait_wake.py:211-227`; `fail_next_realloc` set at lines 209, 215 and 221 (cleared at 225), its fixture at 45 and 47. - **1 line, a `PASS:` summary string.** All eight assertions exist here and are absent from `91add521`. No case exists at neither branch, so this is a move, not a loss. ## What stayed in #2141 The periodic-timer consumption and the two-thread concurrent-wait case remain in `91add521` and are absent here. **Rebase status (2026-11-25, current):** `a86c8e464` → `80f9a3713` onto `main @ 8f7300756701b7c9a278e576bb075ac20e622a32`. Stable patch-id `9795739d3333d65f83e7abe01d6647e4ea71f334` is unchanged and main's old-base→new-main file intersection with this PR is **empty**. The evidence already named below (suite, platform, in-game and measurement, as applicable) therefore still stands at the historical heads that produced it. Earlier rebase notes are history; where they say "this head", they mean the evidence commit named beside that run, not `80f9a3713`. ## Testing **Rebase (2026-11-25).** Rebased onto `origin/main` `be663a08a30fa953420104d3cef6877bed6674a2`. Old head `01324116f6ce26be10bd196fa7958e85744bc33d` → new head `a86c8e4644d55a18e7c7d7eedd19d51061b4e3d9`. `git diff -U0 8aa5ab87..01324116` and `git diff -U0 be663a08a3..a86c8e46` hold the identical changed-line set (60 added/removed lines, 0 differing), so the rebase changed nothing this PR writes. Main's new commits touch neither `host/nn_os_sync.c` nor `tests/test_multiwait_wake.py` (the intersection is empty), so the in-game, Windows and suite results below still describe this PR's code; they were taken at `01324116` and this rebase is the only change since. No suite re-run is owed. Note for the merge: #2445 and #2141 both edit `tests/test_multiwait_wake.py` at different lines, and the pair conflicts there even though each is clean against `main`; the second to merge needs that one-file resolution. **Tested:** Tested in game at 01324116 (v3.2.0-14), windowed at 948x1036 on HDMI-A-2 (Hyprland, output 3840x2160), 60.1 fps: Kokiri Forest (child), ~42 s of play after warm-up (3,126 frames between the play-start and play-end shots, 600 of them the warm-up), age child, life 12/12, no crash, clean quit (exit 0). Linux/Hyprland (Wayland), RTX 4070 Ti, driver 620.73.04. The harness prints 120 s; the measured play was 42 s — the label counts loop iterations, not frames. The earlier `--force` blessing is superseded: the claim now rests on a real in-game result, not a blessed one. **The fix-test, both ways.** The test file as committed here, built against `main`'s `host/nn_os_sync.c` (`8aa5ab87`), stops in the new failed-`realloc` case: the fixture prints nothing and dies with `rc=-11` (SIGSEGV) in both modes — `main` writes through the NULL `realloc` returned — and the test exits 1 at `FAIL: targeted`. At this head the same file prints `targeted: ok`, `all: ok` and `PASS: … allocation failure preserves wakes, links and moves nothing, and says so once`, exit 0. Control: `main`'s own older test file run at `main` passes, so the failure is the new case against `main`'s code, not a broken fixture. Both were re-run on 2026-11-24 and reproduced their logs byte for byte. **`mise run test` at this head.** The full suite ran at `01324116f6ce26be10bd196fa7958e85744bc33d` on 2026-11-24: header `961 checks, 18 skipped, 5 at once (linux)`, summary `942 passed, 19 failed, 18 skipped in 403 s (linux, 5 at once)`, JUnit `tests="979" failures="19" skipped="18" time="403.485"` — 961 ran + 18 skipped = 979, and 942 + 19 = 961. Every one of the 19 failing ids is a CORE id of the suite rule's AMENDMENT 1 and carries that id's exception class; no id outside CORE∪FLAKY failed; the 18 skips are the baseline's, with no head-declared addition. Verdict under AMENDMENT 1: **pass** (counts are not compared). Log `prrefresh-logs/suite-2445-01324116.log`, sha256 `1856864fef9c3cc87ce5e1f1d55b62a2987aa1dd456f1fc86f58f32d3ce20410`; JUnit `prrefresh-logs/suite-2445-01324116.xml`, sha256 `915c559947fcd2e0732fdbbdccf702fc01297d9618fa31570a043940522beb60`; comparison witness `prrefresh-logs/suite-2445-01324116.compare.txt`, beside `.head` (the PR head), `.start`, `.end` and `.exit` (`1`). **Tested on Windows (llvm-mingw).** At `01324116` on a Windows 11 x86-64 box (Acer Nitro AN515-57, i5-11400H, llvm-mingw 20261104 UCRT), `nx2\build.py --standalone` with `RX_VK_ONLY=1` compiled 268 renderer objects of this head and linked them: `compiled in 190 s, 0 failed`, link 1 s, 6 jobs, `lifted code … (0 files)` in the log, so no game data was read. Result: `C:\Users\daze\longshot-2445\work\sa\build\longshot_vk.dll`, 17,704,960 bytes, sha256 `3e8b0af5f540d49846bc0e44e2e28123617d4b662e0ac1c615834a25b8b9b858`, PE32+ (`0x20B`) `IMAGE_FILE_MACHINE_AMD64` / `IMAGE_SUBSYSTEM_WINDOWS_GUI`, exporting `mkwvk_init`, `mkwvk_close_asked`, `mkwvk_crash_close` and `mkwvk_crash_page`; `llvm-strings` finds `01324116 (source 58358c6a)` in it. The checkout's `git rev-parse HEAD` was `01324116f6ce26be10bd196fa7958e85744bc33d` (`.head` beside the log); build log `build-01324116.log`, sha256 `70cc3a79c5ce56e35bde72b62478c3c65c89be94f7ca1583e628626eff0679e2`. The file this PR changes compiles as well: `host/nn_os_sync.c` → `host_nn_os_sync.obj`, 136,318 bytes, sha256 `fd466fdbd17b1386139b0936b4f85d8be5560eae1e7723568c4186d618456d0c`, COFF machine `0x8664`, with `nx2/build.py`'s own host flags. That was the renderer DLL link, not the single-object compile the earlier tree had; **the whole pack then ran at this head on the same box, windowed:** `longshot.exe` 577,531,904 bytes, sha256 `ccb5b8c7c7fa493d875f1dc6f8676e1a26839fc7181b5a828c393fa381e91f48`, on the NVIDIA GeForce GTX 1650, driver `610.62`; the LOW MEMORY dialog was dismissed with `WM_CLOSE` before play. The game window was pid 5280, handle `1049456`, title `Longshot`, rect `77,77,1371,835` (1294x758), `visible=True` at the in-play, mid-play and end-play checks; play ran from frame 3016 at 36.0 fps to frame 5882 at **46.1 fps**, both samples in `KokiriForest_Child`, 2,866 frames over 64 s of wall time, then `exit_code 0` / `stop exit`, with 0 `vk: no window` and 0 `could not start` lines. Log `runs\win-2445\log.txt` (783,674 bytes, sha256 `60af2ac0e0ab6bd63b6350c8b0d83a884bec1d60c4d96a0897ee45e4ccadee6c`) and smoke log `smoke-01324116.log` (25,806 bytes, sha256 `9036f86f924a1b07f3438c9132e177ae221c37d960d3ed1ddbaa5000ac15ab5d`); the screenshots and the game data stayed on that box, since nothing left it. **Still to test:** - **Done** — the Windows (llvm-mingw) link at this head (Tested, by hand). ## Measurements **Verdict:** no in-game before/after is claimed — `main` was not run in game for this change — so the measurement is the test: it fails on `main`'s source, in the case the fix adds, and passes at this head. The windowed in-game run at this head is the evidence that the change plays: 60.1 fps, `exit_code: 0`. The test, both ways (`python3 -I -B tests/test_multiwait_wake.py`, Linux on this PC, `clang++`, no game and no GPU): | | Before: main @ 8aa5ab87 | After: this PR @ 01324116 | |---|---|---| | `tests/test_multiwait_wake.py`, the head's file against each source | FAIL: `targeted:` empty, `FAIL: targeted`, fixture `rc=-11` (SIGSEGV) in both modes, exit 1 | PASS: `targeted: ok`, `all: ok`, exit 0 | - `~/.local/share/longshot-dev/prready-2026-11-24/mw-main-headtest.log` — the whole test on `main`'s source: `targeted:` prints nothing, then `FAIL: targeted`, exit 1. sha256 `9ad0e640e254c14fe64d0186bbe7c2fa5daeaf3c3ce0d380a8cc00dd514b2ac9` - `~/.local/share/longshot-dev/prready-2026-11-24/mw-main-rc.log` — the same fixture's child return code: `targeted: rc=-11 (SIGSEGV)`, `all: rc=-11 (SIGSEGV)`. sha256 `8ed5fcb7fe9990cccb359f570489cc580a8b1078d40169134eb9ebcb12e5fbab` - `~/.local/share/longshot-dev/prready-2026-11-24/mw-01324116.log` — at this head: `targeted: ok`, `all: ok`, exit 0. sha256 `61cda68ddd03349b38541bdab8dd2ba11b2c07c2ad9ea66a784baaf120b0e163` - Control, `~/.local/share/longshot-dev/prready-2026-11-24/mw-main.log` — `main`'s own test file at `main` passes. sha256 `9921bac836774e1821456ec7712aa2b46f356b0b254da6415846956da60596c8` **The windowed in-game run at this head.** `01324116` (`v3.2.0-14-g01324116f`, source `58358c6a`), Kokiri Forest (`KokiriForest_Child`, child), on the 3840x2160 screen and windowed — the log carries `sdl: SDL3` and a `1896x2072` swapchain, and no `vk: no window` line. 60.1 fps at the play-end sample; 3,126 frames between the play-start and play-end shots (`present` 1819 → 4945), 600 of them the 10 s warm-up, so (3,126 − 600) / 60 = 42.1 s of measured play; `exit_code: 0`. The window is `1896x2072`, the 2× buffer of a 948x1036 logical window; the logical size and `HDMI-A-2` are reported, unsubstantiated here (no `hyprctl clients -j` capture was kept). Driver `620.73.04`. Queue ticket `1082824` — reported, unsubstantiated: the queue directory now holds only `.lock`. Artefacts: `~/.local/share/longshot-dev/smoke-2026-11-24/b-queue-output.log` (line 4 and line 10 `window 1896x2072`; line 10 `fps 60.1`; line 7 `== warm-up 10 s ==`; line 52 `"exit_code": 0`; line 144 `state: finished exit: 0`), sha256 `5ab4b16c934dc1840c93bc2647f5a536534700e63c7bcb6c54998c8477db2f63`; `~/.local/share/longshot-dev/runs/control/b-holder-alloc-windowed-20261124/log.txt` (line 61 `vk: driver: NVIDIA 620.73.04`; line 73 `screen 3840x2160 at 165 Hz`; line 101 `swapchain 1896x2072`; line 1701 `present 1819` at the play-start shot; line 2603 `3720 presents, 60.1 fps`; line 3223 `present 4945` at the play-end shot; the log has no `vk: no window` line), sha256 `29294f476e2497e40bc4861e5774b4511e9ba9a726954072a5707990adb228f6`; `~/.local/share/longshot-dev/runs/control/b-holder-alloc-windowed-20261124/manifest.json` (`present` 1819 → 4945, `exit_code` 0), sha256 `2d1613e5a525d8cdc1efb523c532be0fa032226996421bf45594b4db52a63926`. ## Risks **An allocation that fails now costs a holder, not the process.** Both calls are `void`, so no error reaches the game: a refused `LinkMultiWaitHolder` leaves the holder out of that multi-wait, and a refused `MoveAllMultiWaitHolder` leaves every holder in the source list — the list unchanged, as the test asserts. The refusal is logged once per process, so it is visible in the log rather than silent. On a machine under enough memory pressure the symptom becomes a wait that never completes instead of a write through NULL — the deliberate trade, and why the log line matters. **Holder-array growth is now a hard error.** There is no retry and no fallback: when `realloc` fails the operation is refused whole. That is what the fix is for, but nothing masks a genuine allocation failure any more. **`MoveAllMultiWaitHolder(mw, mw)` is now a no-op.** It used to append a list to itself until growth failed and the write through NULL followed. No caller is known to rely on the old behaviour; one that did would now move nothing. **Blast radius.** `host/nn_os_sync.c` alone, plus its test: the link, unlink, unlink-all and move-all entry points of `nn::os`, reached by any game that waits on several objects at once. In normal play nothing observable changes: no switch, no file format, no save, no `longshot_options.ini` key, no cache; the refusal line is the only new output, and only after a failed `realloc`. A revert is the whole rollback. **Not covered.** The Windows path of `realloc` and `hos_log` is untested (the Windows build is parked), and the test models the holder arrays and the wake counting — not threads, timing or the GPU. The in-game run exercises the path that allocates normally; the refusal path itself rests on the test alone. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. — Rebased head `80f9a3713` is directly on `main @ 8f7300756701b7c9a278e576bb075ac20e622a32`; the preserved diff is the single topic described in Summary. - [x] **Tested on my own PC, in the game for a change the game runs.** 01324116 in game: kokiri-start repo save → Kokiri Forest (KokiriForest_Child, child), ~42 s measured play after warm-up, exit 0, no crash. - [x] **`mise run test` passes.** `suite-2445-01324116` at `01324116`: `942 passed, 19 failed, 18 skipped in 403 s (linux, 5 at once)`; all 19 failures are CORE ids of the suite rule's AMENDMENT 1 with matching exception classes, 0 ids outside CORE∪FLAKY, the 18 skips are the baseline's. Log, JUnit and witness with their sha256 in Testing. - [x] **Measured against `main`, or Measurements says why there is nothing to measure.** A fix's measurement is its test output on `main` and here; both ran — `main` fails (`targeted:` empty, `rc=-11`, exit 1), this head passes (`targeted: ok`, `all: ok`, exit 0) — and Measurements holds them with their logs' sha256. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. — `git diff --name-status 8aa5ab87..01324116` lists only `host/nn_os_sync.c` and `tests/test_multiwait_wake.py`. ### When it applies - [x] **A fix: a game-free test that fails on `main` and passes here.** `tests/test_multiwait_wake.py` at this head, built against `main`'s `host/nn_os_sync.c`, dies in the new failed-`realloc` case (`rc=-11`, SIGSEGV, exit 1); at this head it prints `targeted: ok`, `all: ok`, exit 0. Logs and sha256 in Measurements. - [x] A check under `tests/` that reads changed source is updated, not weakened. — `tests/test_multiwait_wake.py` extracts `host/nn_os_sync.c`, and the diff adds the case block and assertions without removing any. - [x] **Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.** Windows: **linked** at `01324116`, not a single-object compile — `nx2\build.py --standalone` with `RX_VK_ONLY=1` compiled 268 renderer objects and linked `longshot_vk.dll` on a Windows 11 x86-64 box (`compiled in 190 s, 0 failed`, link 1 s) from a checkout whose `git rev-parse HEAD` is `01324116f6ce…`: `C:\Users\daze\longshot-2445\work\sa\build\longshot_vk.dll`, 17,704,960 bytes, sha256 `3e8b0af5f540d49846bc0e44e2e28123617d4b662e0ac1c615834a25b8b9b858`, PE32+ `IMAGE_FILE_MACHINE_AMD64` / `IMAGE_SUBSYSTEM_WINDOWS_GUI`, exports `mkwvk_init`, `mkwvk_close_asked`, `mkwvk_crash_close`, `mkwvk_crash_page`, and the DLL carries `01324116 (source 58358c6a)`. The changed file compiles too: `host/nn_os_sync.c` → 136,318-byte COFF object `host_nn_os_sync.obj` (machine `0x8664`, sha256 `fd466fdb…`). Linux: unchanged by this run. **Run: `longshot.exe` with the whole pack at this head**, windowed on the NVIDIA GeForce GTX 1650 (driver `610.62`) after the LOW MEMORY dialog was dismissed with `WM_CLOSE`: 577,531,904 bytes, sha256 `ccb5b8c7c7fa493d875f1dc6f8676e1a26839fc7181b5a828c393fa381e91f48`, window handle `1049456` (pid 5280, rect `77,77,1371,835`, 1294x758, `visible=True`), play ending at 46.1 fps after 2,866 frames in 64 s in `KokiriForest_Child`, `exit_code 0`; `runs\win-2445\log.txt` and `smoke-01324116.log` on that box. The screenshots and game data stayed there. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. — `01324116` carries `Assisted-by: opencode (DeepSeek V4.1 Flash)`. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. — Merge gate: outstanding items remain in Still to test or are confirmed during review; this update does not tick it. - [ ] Tier 1 hardware it can affect is tested (`docs/dev/standards.md`, "Hardware tiers"). — Merge gate: platform coverage is settled during review; this update does not claim new hardware coverage. - [ ] Approved in review, every comment answered. — Awaiting reviewer approval and resolution of any review comments. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. — Awaiting CI on the current head; this update does not claim a CI run.
The regex is assigned and never read, which ruff reports as F841; the check it described is the
allowlist below it, so nothing is lost.

Assisted-by: opencode (DeepSeek V4.1 Flash)
fix(os): refuse a multi-wait link or move whose holder array cannot grow
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 5s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
01324116f6
Split out of #2141: this is independent of
that branch's periodic timer consumption.

LinkMultiWaitHolder stored realloc's result unchecked and then wrote mw->links[nlinks++], so an
allocation failure wrote through NULL. It is now a refusal (the holder is not linked), as a failed
watch registration is.

MoveAllMultiWaitHolder grew the destination one holder at a time with the same unchecked realloc,
and called with to == from it appended to the list it was iterating: that doubled nlinks until
growth failed, then wrote through NULL. It is now a no-op onto itself, and grows the destination
once for the whole move, refusing the move whole if that allocation fails: by design from then
keeps its holders, so the guest merges a source that is still there rather than losing waits it
had.

Both refusals are void SDK calls with no error to return, so each says so in one hos_log line per
process (logged with mw_lock released, since logging takes the log's own lock).

test_multiwait_wake: a fresh multi-wait's first link with a failing realloc links nothing, logs one
line and does not crash; a link after it links; a self-move changes, allocates and logs nothing; a
failed move leaves the source's holders where they were and logs nothing more than the one line a
process gets. The test passes at this head, run through the PC's queue.

Assisted-by: opencode (DeepSeek V4.1 Flash)
Author
Contributor

In-game run at 01324116 recorded in Testing: Kokiri Forest, ~42 s measured (harness label 120 s corrected).

In-game run at 01324116 recorded in Testing: Kokiri Forest, ~42 s measured (harness label 120 s corrected).
Author
Contributor

Windows testing dropped by the human 2026-11-24: the Host-code-builds-on-Windows box stays unticked, so this PR stays WIP. No link and no Test Farm request are planned.

Windows testing dropped by the human 2026-11-24: the Host-code-builds-on-Windows box stays unticked, so this PR stays WIP. No link and no Test Farm request are planned.
dazemc changed title from WIP: fix(os): refuse a multi-wait link or move whose holder array cannot grow to fix(os): refuse a multi-wait link or move whose holder array cannot grow 2026-11-24 16:16:48 +00:00
dazemc force-pushed fix/os-multiwait-holder-alloc from 01324116f6
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 5s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
to a86c8e4644
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website builds (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website builds (pull_request) Blocked by required conditions
Website / Website preview, build (pull_request) Blocked by required conditions
Website / Website preview, upload (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 5s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test) (pull_request) Has been cancelled
CI / longshot-builder end to end (synthetic game) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
2026-11-25 09:03:49 +00:00
Compare
Author
Contributor

Description: Testing names the machine instead of a distribution; no other change.

Description: Testing names the machine instead of a distribution; no other change.
dazemc force-pushed fix/os-multiwait-holder-alloc from a86c8e4644
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website builds (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website builds (pull_request) Blocked by required conditions
Website / Website preview, build (pull_request) Blocked by required conditions
Website / Website preview, upload (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 5s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test) (pull_request) Has been cancelled
CI / longshot-builder end to end (synthetic game) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
to 80f9a3713b
Some checks are pending
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / What the change needs (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test) (pull_request) Blocked by required conditions
CI / longshot-builder end to end (synthetic game) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 3/4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 4/4) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 21s
2026-11-25 17:55:06 +00:00
Compare
Author
Contributor

Rebased a86c8e464 to 80f9a3713 on main 8f7300756; patch-id unchanged and intersection empty. Existing suite, in-game and Windows evidence stands.

Rebased a86c8e464 to 80f9a3713 on main 8f7300756; patch-id unchanged and intersection empty. Existing suite, in-game and Windows evidence stands.
Some checks are pending
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / What the change needs (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test) (pull_request) Blocked by required conditions
CI / longshot-builder end to end (synthetic game) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 3/4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 4/4) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 21s
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/os-multiwait-holder-alloc:dazemc-fix/os-multiwait-holder-alloc'
git switch 'dazemc-fix/os-multiwait-holder-alloc'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2445
No description provided.