fix(os): refuse a multi-wait link or move whose holder array cannot grow #2445
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2445
Loading…
Reference in a new issue
No description provided.
Delete branch "dazemc/Longshot:fix/os-multiwait-holder-alloc"
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?
Summary
mw_linkandmw_move_allgrow a multi-wait's holder array withrealloc. On failure the old code kept going and wrote through the stale or null result: a failedLINKcould link a holder it could not store, and a failedMOVEALLcould 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 withfail_next_realloccases.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, heada86c8e4644d55a18e7c7d7eedd19d51061b4e3d9, based onbe663a08a30fa953420104d3cef6877bed6674a2(currentmain). Diff againstmain: 2 files changed, 54 insertions(+), 9 deletions(-).What moved here, case by case
Between
12ed3a32(the pre-split head of #2141) and91add521(#2141 now),tests/test_multiwait_wake.pylost 29 lines. Each is accounted for:static int logs;andhos_log(...), the counter the refusal messages use; present here.LINK; a link after that failure;MOVEALL(mw, mw)onto itself; a failedMOVEALL(other, mw). Eight assertions, attests/test_multiwait_wake.py:211-227;fail_next_reallocset at lines 209, 215 and 221 (cleared at 225), its fixture at 45 and 47.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
91add521and are absent here.Rebase status (2026-11-25, current):
a86c8e464→80f9a3713ontomain @ 8f7300756701b7c9a278e576bb075ac20e622a32. Stable patch-id9795739d3333d65f83e7abe01d6647e4ea71f334is 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, not80f9a3713.Testing
Rebase (2026-11-25). Rebased onto
origin/mainbe663a08a30fa953420104d3cef6877bed6674a2. Old head01324116f6ce26be10bd196fa7958e85744bc33d→ new heada86c8e4644d55a18e7c7d7eedd19d51061b4e3d9.git diff -U0 8aa5ab87..01324116andgit diff -U0 be663a08a3..a86c8e46hold the identical changed-line set (60 added/removed lines, 0 differing), so the rebase changed nothing this PR writes. Main's new commits touch neitherhost/nn_os_sync.cnortests/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 at01324116and this rebase is the only change since. No suite re-run is owed. Note for the merge: #2445 and #2141 both edittests/test_multiwait_wake.pyat different lines, and the pair conflicts there even though each is clean againstmain; 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
--forceblessing 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'shost/nn_os_sync.c(8aa5ab87), stops in the new failed-realloccase: the fixture prints nothing and dies withrc=-11(SIGSEGV) in both modes —mainwrites through the NULLreallocreturned — and the test exits 1 atFAIL: targeted. At this head the same file printstargeted: ok,all: okandPASS: … allocation failure preserves wakes, links and moves nothing, and says so once, exit 0. Control:main's own older test file run atmainpasses, so the failure is the new case againstmain's code, not a broken fixture. Both were re-run on 2026-11-24 and reproduced their logs byte for byte.mise run testat this head. The full suite ran at01324116f6ce26be10bd196fa7958e85744bc33don 2026-11-24: header961 checks, 18 skipped, 5 at once (linux), summary942 passed, 19 failed, 18 skipped in 403 s (linux, 5 at once), JUnittests="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). Logprrefresh-logs/suite-2445-01324116.log, sha2561856864fef9c3cc87ce5e1f1d55b62a2987aa1dd456f1fc86f58f32d3ce20410; JUnitprrefresh-logs/suite-2445-01324116.xml, sha256915c559947fcd2e0732fdbbdccf702fc01297d9618fa31570a043940522beb60; comparison witnessprrefresh-logs/suite-2445-01324116.compare.txt, beside.head(the PR head),.start,.endand.exit(1).Tested on Windows (llvm-mingw). At
01324116on a Windows 11 x86-64 box (Acer Nitro AN515-57, i5-11400H, llvm-mingw 20261104 UCRT),nx2\build.py --standalonewithRX_VK_ONLY=1compiled 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, sha2563e8b0af5f540d49846bc0e44e2e28123617d4b662e0ac1c615834a25b8b9b858, PE32+ (0x20B)IMAGE_FILE_MACHINE_AMD64/IMAGE_SUBSYSTEM_WINDOWS_GUI, exportingmkwvk_init,mkwvk_close_asked,mkwvk_crash_closeandmkwvk_crash_page;llvm-stringsfinds01324116 (source 58358c6a)in it. The checkout'sgit rev-parse HEADwas01324116f6ce26be10bd196fa7958e85744bc33d(.headbeside the log); build logbuild-01324116.log, sha25670cc3a79c5ce56e35bde72b62478c3c65c89be94f7ca1583e628626eff0679e2. The file this PR changes compiles as well:host/nn_os_sync.c→host_nn_os_sync.obj, 136,318 bytes, sha256fd466fdbd17b1386139b0936b4f85d8be5560eae1e7723568c4186d618456d0c, COFF machine0x8664, withnx2/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.exe577,531,904 bytes, sha256ccb5b8c7c7fa493d875f1dc6f8676e1a26839fc7181b5a828c393fa381e91f48, on the NVIDIA GeForce GTX 1650, driver610.62; the LOW MEMORY dialog was dismissed withWM_CLOSEbefore play. The game window was pid 5280, handle1049456, titleLongshot, rect77,77,1371,835(1294x758),visible=Trueat 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 inKokiriForest_Child, 2,866 frames over 64 s of wall time, thenexit_code 0/stop exit, with 0vk: no windowand 0could not startlines. Logruns\win-2445\log.txt(783,674 bytes, sha25660af2ac0e0ab6bd63b6350c8b0d83a884bec1d60c4d96a0897ee45e4ccadee6c) and smoke logsmoke-01324116.log(25,806 bytes, sha2569036f86f924a1b07f3438c9132e177ae221c37d960d3ed1ddbaa5000ac15ab5d); the screenshots and the game data stayed on that box, since nothing left it.Still to test:
Measurements
Verdict: no in-game before/after is claimed —
mainwas not run in game for this change — so the measurement is the test: it fails onmain'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):8aa5ab8701324116tests/test_multiwait_wake.py, the head's file against each sourcetargeted:empty,FAIL: targeted, fixturerc=-11(SIGSEGV) in both modes, exit 1targeted: ok,all: ok, exit 0~/.local/share/longshot-dev/prready-2026-11-24/mw-main-headtest.log— the whole test onmain's source:targeted:prints nothing, thenFAIL: targeted, exit 1. sha2569ad0e640e254c14fe64d0186bbe7c2fa5daeaf3c3ce0d380a8cc00dd514b2ac9~/.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). sha2568ed5fcb7fe9990cccb359f570489cc580a8b1078d40169134eb9ebcb12e5fbab~/.local/share/longshot-dev/prready-2026-11-24/mw-01324116.log— at this head:targeted: ok,all: ok, exit 0. sha25661cda68ddd03349b38541bdab8dd2ba11b2c07c2ad9ea66a784baaf120b0e163~/.local/share/longshot-dev/prready-2026-11-24/mw-main.log—main's own test file atmainpasses. sha2569921bac836774e1821456ec7712aa2b46f356b0b254da6415846956da60596c8The windowed in-game run at this head.
01324116(v3.2.0-14-g01324116f, source58358c6a), Kokiri Forest (KokiriForest_Child, child), on the 3840x2160 screen and windowed — the log carriessdl: SDL3and a1896x2072swapchain, and novk: no windowline. 60.1 fps at the play-end sample; 3,126 frames between the play-start and play-end shots (present1819 → 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 is1896x2072, the 2× buffer of a 948x1036 logical window; the logical size andHDMI-A-2are reported, unsubstantiated here (nohyprctl clients -jcapture was kept). Driver620.73.04. Queue ticket1082824— 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 10window 1896x2072; line 10fps 60.1; line 7== warm-up 10 s ==; line 52"exit_code": 0; line 144state: finished exit: 0), sha2565ab4b16c934dc1840c93bc2647f5a536534700e63c7bcb6c54998c8477db2f63;~/.local/share/longshot-dev/runs/control/b-holder-alloc-windowed-20261124/log.txt(line 61vk: driver: NVIDIA 620.73.04; line 73screen 3840x2160 at 165 Hz; line 101swapchain 1896x2072; line 1701present 1819at the play-start shot; line 26033720 presents, 60.1 fps; line 3223present 4945at the play-end shot; the log has novk: no windowline), sha25629294f476e2497e40bc4861e5774b4511e9ba9a726954072a5707990adb228f6;~/.local/share/longshot-dev/runs/control/b-holder-alloc-windowed-20261124/manifest.json(present1819 → 4945,exit_code0), sha2562d1613e5a525d8cdc1efb523c532be0fa032226996421bf45594b4db52a63926.Risks
An allocation that fails now costs a holder, not the process. Both calls are
void, so no error reaches the game: a refusedLinkMultiWaitHolderleaves the holder out of that multi-wait, and a refusedMoveAllMultiWaitHolderleaves 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
reallocfails 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.calone, plus its test: the link, unlink, unlink-all and move-all entry points ofnn::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, nolongshot_options.inikey, no cache; the refusal line is the only new output, and only after a failedrealloc. A revert is the whole rollback.Not covered. The Windows path of
reallocandhos_logis 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
main; the title is a Conventional Commit. — Rebased head80f9a3713is directly onmain @ 8f7300756701b7c9a278e576bb075ac20e622a32; the preserved diff is the single topic described in Summary.01324116in game: kokiri-start repo save → Kokiri Forest (KokiriForest_Child, child), ~42 s measured play after warm-up, exit 0, no crash.mise run testpasses.suite-2445-01324116at01324116: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.main, or Measurements says why there is nothing to measure. A fix's measurement is its test output onmainand here; both ran —mainfails (targeted:empty,rc=-11, exit 1), this head passes (targeted: ok,all: ok, exit 0) — and Measurements holds them with their logs' sha256.third_party/untouched; nothing GPL-incompatible. —git diff --name-status 8aa5ab87..01324116lists onlyhost/nn_os_sync.candtests/test_multiwait_wake.py.When it applies
mainand passes here.tests/test_multiwait_wake.pyat this head, built againstmain'shost/nn_os_sync.c, dies in the new failed-realloccase (rc=-11, SIGSEGV, exit 1); at this head it printstargeted: ok,all: ok, exit 0. Logs and sha256 in Measurements.tests/that reads changed source is updated, not weakened. —tests/test_multiwait_wake.pyextractshost/nn_os_sync.c, and the diff adds the case block and assertions without removing any.01324116, not a single-object compile —nx2\build.py --standalonewithRX_VK_ONLY=1compiled 268 renderer objects and linkedlongshot_vk.dllon a Windows 11 x86-64 box (compiled in 190 s, 0 failed, link 1 s) from a checkout whosegit rev-parse HEADis01324116f6ce…:C:\Users\daze\longshot-2445\work\sa\build\longshot_vk.dll, 17,704,960 bytes, sha2563e8b0af5f540d49846bc0e44e2e28123617d4b662e0ac1c615834a25b8b9b858, PE32+IMAGE_FILE_MACHINE_AMD64/IMAGE_SUBSYSTEM_WINDOWS_GUI, exportsmkwvk_init,mkwvk_close_asked,mkwvk_crash_close,mkwvk_crash_page, and the DLL carries01324116 (source 58358c6a). The changed file compiles too:host/nn_os_sync.c→ 136,318-byte COFF objecthost_nn_os_sync.obj(machine0x8664, sha256fd466fdb…). Linux: unchanged by this run. Run:longshot.exewith the whole pack at this head, windowed on the NVIDIA GeForce GTX 1650 (driver610.62) after the LOW MEMORY dialog was dismissed withWM_CLOSE: 577,531,904 bytes, sha256ccb5b8c7c7fa493d875f1dc6f8676e1a26839fc7181b5a828c393fa381e91f48, window handle1049456(pid 5280, rect77,77,1371,835, 1294x758,visible=True), play ending at 46.1 fps after 2,866 frames in 64 s inKokiriForest_Child,exit_code 0;runs\win-2445\log.txtandsmoke-01324116.logon that box. The screenshots and game data stayed there.Assisted-by:/Co-Authored-By:trailers. —01324116carriesAssisted-by: opencode (DeepSeek V4.1 Flash).Ready to merge
docs/dev/standards.md, "Hardware tiers"). — Merge gate: platform coverage is settled during review; this update does not claim new hardware coverage.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.In-game run at
01324116recorded in Testing: Kokiri Forest, ~42 s measured (harness label 120 s corrected).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.
WIP: fix(os): refuse a multi-wait link or move whose holder array cannot growto fix(os): refuse a multi-wait link or move whose holder array cannot grow01324116f6a86c8e4644Description: Testing names the machine instead of a distribution; no other change.
a86c8e464480f9a3713bRebased
a86c8e464to80f9a3713on main8f7300756; patch-id unchanged and intersection empty. Existing suite, in-game and Windows evidence stands.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.