World freezes about 2 minutes in: a job thread spins at image+0x50eb80f, then the watchdog ends the run at image+0x55e56f8 #456
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?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by maaalrey on 2026-11-27T20:45:41Z.
Mac
Apple M4 Max, 128 GB, macOS 27.2.1. Apple's Metal Shader Converter 4.0 beta 3 in /usr/local/lib. Series X, windowed, warm shader cache.
Commit
c1b9587(5 of 5 runs) and86786a7(1 run; two more runs there were stopped early by my own guard at a Metal error, which I am looking at separately). Two local changes only: the sound output is replaced by the silent one, and the thread dump prints registers and a few words of title memory.What happens
New game from an empty data folder, keys scripted through the setup screens. On
c1b9587, all five runs:native draws so farline with new draws (logged every 64 frames, so the freeze is somewhat later)0xc0000005 at image+0x55e56f8No GPU error, no command-buffer failure and no host panic in these runs. The fifth run had no thread dump and no extra variables, and ended the same way at 281 s, so the dump is not what triggers the faults. On
86786a7the same thing: last new draws at 204 s, the two faults at 284 s.VICTORY_DUMP_THREADS=270shows the same two threads in the five runs that had a dump:WaitForSingleObject, title image+[509898d, 7b5a9d, 21b6d0d, 81269b, 53ec040, 53ebf3a, ...][50eb80f..50eb9d1, 31962, 317fd, 25d801b, 221c29c, 2215eca]. The top address moves inside that range from dump to dump; the rest of the chain is the same.With
--console series-sonc1b9587the freeze did not come: two new-game runs stayed in the world for about 220 s and 380 s (the first ended on my timer, the second at a Metal error). All the runs above are Series X.Loading an existing story save instead of starting a new game freezes with the same two chains right at world entry (DirectStorage goes quiet at about 83 to 85 thousand requests): 3 of the 3 dumped runs that finished loading on
c1b9587. Some earlier runs on that path did get into the world, and the freeze was there with sound on too. On that path Series S froze as well (3 of 3).What the spinning thread seems to be doing (a guess, from words read in the stopped process; nothing from the game attached)
The loop around image+0x50eb80f probes a hash table (pointer at image+0x876fc50, group count at +0x876fc48) for a 32-bit handle, and it has no exit for "not there". In all six dumps where I printed the table, the handle it looks for is absent and the table holds an entry for the same pool slot with the generation one lower:
86786a7In the one dump where I also had the pool's generation word for that slot, it looked like a free-list link (low bits = index + 1), unlike the live slots around it. So my reading is that the job is handed an object that was already freed: it looks up the slot's new handle, never finds it, the main thread waits for that job, and the frame watchdog fires.
I do not know which host behaviour lets the object go while the job still refers to it. I can run a build with more tracing if that helps.
About image+0x55e56f8
#147 was closed with this address as the follow-on of the first-world-frame watchdog. Here the first world frame is fine and a few hundred world frames are presented before the freeze, so this is a second way to reach it.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by alexballvideos-netizen on 2026-11-27T21:38:01Z.
A static reading of the spinning loop, from my own copy of the exe. It supports your guess and narrows it. No code quoted, just what it does.
Conclusion: the job still holds a pointer to an object that another path has already freed (not reallocated). The bug is the ordering between that free and the job, not the table.
Other users of the same table, for whoever traces it next:
Reproduction on an M3 Max, 36 GB, Series X:
0x2215c35fault, at about 270 s. That run was mainb998bb65withVICTORY_DEPTH_TWINS=0.A next step that would name the freeing path is a write watch on the generation word of the slot the job holds. I don't have one yet. If you can catch the slot early (with your thread-dump build), a
VICTORY_FIND_QWORDon the object pointer, taken while it's still live, would show which other structures still point at it.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by derz92 on 2026-11-27T21:41:12Z.
A data point that may name the cause: on this Mac, this freeze goes away with texture copy-back.
M5 Max, 36 GB, macOS 26.5, Series S, warm cache, tree
b998bb65+ #437 (+ #358) with #437's switches.WaitForSingleObjectat[509898d, 7b5a9d, 21b6d0d, 81269b, 53ec040, 53ebf3a, ...](your stack), and one thread in title code at[50eb823, 31962, 317fd, 25d801b, 221c29c, 2215eca]. That's your spinning loop.VICTORY_TEXTURE_BACK=1: 0 of 7 runs froze. One copied back everything (274 textures). Six copied back only textures of 8 KiB or less (a local size limit inwrite_back; 51 copied, 214 skipped). Each played through the cutscene to the player-control prompt and kept presenting to its 200 to 360 s world cap (frames 1850 to 1990).The cold-cache run without copy-back also got past it, but that's the slower run, consistent with @alexballvideos-netizen's point that the freeze needs enough world frames.
Reading it together with the static analysis above: the title may decide an object can be freed, or that a job's object is still live, from a small GPU-written result it reads on the CPU. Without copy-back that read sees stale bytes, the free happens out of order, and the job later rebuilds a key with generation + 1. The small textures copied back in the passing runs were 1x1 (format 3, 256 B), 54x30, 27x15 and 20x12 (format 42), 10x6 (format 2) and similar. I haven't yet narrowed it to one texture. Bisecting the size limit, or logging which of these the title reads just before the free, would name it. #449 (copy-back by default) would cover this, but on this Mac full copy-back also brings visible block noise (details on #449), so a small-texture limit currently gives both the progress and a clean image.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by derz92 on 2026-11-27T21:54:46Z.
Correction to my count above. One of the seven copy-back runs (8 KiB limit) also stopped presenting, at frame about 1478 (74 s into a 205 s run), the same place as the runs without copy-back. So it's 1 of 7 with copy-back vs 2 of 2 without, not 0 of 7. Another of the seven only reached frame about 1690 before its cap, not 1850+.
Those seven runs also weren't one controlled condition. They used four different builds (some with extra frame timers, which slow the title down), all came after the two control runs, and copy-back itself adds GPU-to-CPU syncs. So copy-back may only change timing, not supply the missing data, and I can't claim it as the cause yet. Next I'll alternate one binary with copy-back on and off, warm cache, several runs each, before saying more.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by derz92 on 2026-11-27T22:16:44Z.
Result of the controlled run I promised. On this Mac, copy-back makes no difference to the freeze.
The setup:
b998bb65+ #437 + #358, plus two local mirror speed-ups that took a world frame from about 520 to 410 ms.VICTORY_TEXTURE_BACKalternating 1/0.All six kept presenting to the cap. So the three freezes I saw earlier at frame about 1480 to 1570 (two without copy-back, one with) came from older, slower builds of the same tree. I withdraw the copy-back hypothesis from my first comment. What's left fits your point that the freeze depends on timing: none in 6 runs of the faster build, 3 in about 9 runs of slower builds. I'll keep logging any freeze here, with its stack.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by derz92 on 2026-11-27T23:29:47Z.
More data on where it happens. Across tonight's runs on this Mac (#437's tree plus local speed changes, Series S, warm cache, 180–300 s world caps), there were 6 freezes. Every one stopped presenting at frame 1478–1573:
About 20 other runs passed that point and kept presenting to their caps (frame 1600–2300). These frozen runs were at very different speeds: frame times of about 400 to 520 ms, and both cold and warm caches. Yet the frame number barely moves, so it seems tied to one moment in the cutscene (just after it starts) rather than to elapsed world time or total frame count. A race that only that moment exposes would fit your freed-slot reading. Roughly 1 run in 4 hits it here.
If anyone has a write-watch build for the slot's generation word, the window to arm it is narrow and predictable: from about frame 1450 to 1600.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by maaalrey on 2026-11-28T01:50:41Z.
Thanks both. An update on current main + #459: the freeze is still there when loading a save, which is a faster way to get it; what the stuck threads hold; and what the sampled frees look like.
M4 Max, 128 GB, macOS 27.2.1, Series S, windowed. Builds:
b998bb65and86cefd22, with #459 unless noted, plus local dump-only changes.Still there with #459, and loading a save gets it quickly
New game from an empty data folder: no freeze in two 600 s runs on
b998bb65(with and without #459), about 800 world frames each at 1.8 to 2.0 fps.Loading an existing story save instead, 28 runs:
b998bb65+ #45986cefd22+ #45986cefd22the first 6 runs all stuck, then 8 of the next 14 loaded. I do not know what changed in between.What the spinning threads hold
In 12 of the stuck runs the dump also read the slot of each object a spinning thread holds (16 objects). All 16 read the same way:
So I read each object as registered at generation 1 and freed since, which matches alexballvideos's reading. On the scan alexballvideos asked about: I ran
VICTORY_FIND_QWORD's scan on the objects at dump time, not while they were live, and it finds each still referenced from many arrays of pool-4 siblings.Which code frees them
A write watch on the whole pages of pool 4's generation entries, armed at 35 s, in two of the stuck runs. It samples (the page stays open for a moment after each hit, so most writes are missed). I am reading a write to an entry whose low bits are all set as a free. Those came from job tasks only, on these chains, image+:
All writes to those pages stop within a second of the stall. The watch did not catch the free of the exact slots the spinners hold (27 and 34 frees sampled in the two runs). So as far as this shows: job tasks (most through image+0x22a2379) free pool-4 objects while another (through image+0x25d801b) still looks them up. What orders them on real hardware I do not know.
One thing that did not explain it
The host reports the Mac's processor count (16 here) to the title, and
SetThreadPriorityand the affinity calls do nothing. With a local switch for the reported count, on86cefd22: 16 → 1 of 8 loaded, 8 → 5 of 9, 4 → 2 of 3. But 5 of the 8 runs at 16 were among the first 6, and in the alternating runs at the end it was 1 of 3 at 16 against 1 of 2 at 8, so I cannot separate it from the drift above. Not a fix either way; the thread dump has 58 threads at every count.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by maaalrey on 2026-11-28T02:31:16Z.
Results on main
8efcff13(which has #499 and #459; plus local dump-only changes), same Mac and settings as above (Series S, windowed, loading the same story save):86cefd22+ #459 (no #499)8efcff13(with #499)All four have the same chain in the dump, image+ [first frame between 50eb80f and 50eb82c, then 31962, 317fd, 25d801b, 221c29c, 2215eca], on 2, 2, 1 and 1 threads. Four runs cannot say whether the rate changed; they do show the freeze still happens on a build that has #499.
Two more observations from
86cefd22, from two further stuck runs (not the two write-watch runs of my earlier comment) that had both the write watch and a local trace of what the title asks for each thread:SetThreadPriority,SetThreadGroupAffinity).WaitForSingleObjectunder a job, image+ [55bfc39, 3d75259, 63e78, 4eaa05a, 221c29c, 2215eca], and the main thread waits at image+ [509898d, 7b5a9d, 21b6d0d, 81269b]. Two runs, so an observation, not a finding.My reading of those two waits (a guess): the function that contains image+0x55bfc39 is the one that empties the table from my earlier comment, and it waits for the lookup jobs to finish first; so once a lookup spins on a freed object, that job and the main thread behind it wait indefinitely (up to the 260 s I watched). I still do not know what keeps the freeing job behind the lookups on real hardware.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by derz92 on 2026-11-28T03:28:23Z.
A lead on what the race involves: dropping two compute shaders' dispatches makes this freeze much more likely.
Setup:
lit-world/base-3plus local speed changes, M5 Max, macOS 26.5, Series S, warm cache, #437's switches. I alternated the same binary with and withoutVICTORY_SKIP_PIPELINES=6a04b371a8e26853,7de0f9db96ddd295(#535). Those are two compute programs that run as long chains in the world, hundreds of dispatches a pass. Each run had a 150 s world cap.Pooled with the night's other runs on this base: 7 of 11 froze with the skip, 2 of 10 without. Every freeze stopped in the same window as before (frames ~1470–1520), with the same main-thread wait.
It's a lead, not a proof: the sample is small, and timing changes too (skipping makes frames about 10% cheaper). Still, if the job's object is freed out of order when work tied to those two programs doesn't run, their outputs (or the fences around them) may be part of what the title waits on before the free. If someone has a write-watch build for the slot's generation word,
VICTORY_SKIP_PIPELINES=6a04b371a8e26853,7de0f9db96ddd295should make the freeze come up about three runs in four here.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by maaalrey on 2026-11-28T04:05:27Z.
/claim
A workaround for the freeze in the lookup loop, on my setup. I am claiming the issue to put it up as an opt-in switch in a draft PR; the claim covers the switch only, not the cause, which is still open for anyone.
The loop the stuck threads sit in (image+0x50eb80f) searches the table group by group and has no way out for a handle that is in no group. Locally I gave it one. Before the title runs, the first byte of the loop's "not in this group, try the next" path (image+0x50eb9d1) becomes an
int3. The handler then does what that path did, unless the group just searched has a free slot (a control byte with bit 7 set); in that case it returns through the function's own exit (image+0x50eb910), which the function already takes for an object with nothing to draw. Nothing is patched unless the code at that place is the counter step and the jump back that I expect.Same Mac, save and settings as in my earlier comments (Series S, windowed, same story save), main
8efcff13:Four baseline runs are few; 0 stuck of 10 against 4 of 4 here and 12 of 20 on the build before is why I am putting it up.
What it does not do: it does not touch the cause, which I still do not know. As I read it, a freed object is skipped for that frame; I have not checked what else that early return skips, and I have not looked for anything missing on screen. "A group with a free slot ends the search" is a guess, from the insert (image+0x554f7e0) taking the first free slot it meets on the same search path.
The switch will be
VICTORY_LOOKUP_EXIT=1, off by default, with the offsets marked as this build's only, tests, and a note in docs/native-host.md. Once the draft PR is up: derz92, alexballvideos, if you can run it on your freezing setups, the log prints a line each time the exit is taken, and whether any run still stops would tell us whether the new-game freeze is the same thing.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T04:05:37Z.
Claimed by @maaalrey. Open a draft pull request with
Refs #456in its description within 24 hours, or the claim expires.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by maaalrey on 2026-11-28T05:20:05Z.
The draft is up: #565, on main
2f4d81e0.To try it: build that branch and run with
VICTORY_LOOKUP_EXIT=1. The log then hasVICTORY_LOOKUP_EXIT: armed at image+0x50eb9d1near the start, and a warning linea lookup met an empty entry before its handle; it returnseach time the exit is taken (the first eight, then at powers of two, with the handle and the counts so far). If it saysnot armed, the code at that place is not the one I patched and nothing was changed.Since the claim comment, two things changed in review: the search now ends only at a control byte of exactly 0x80 (the value the emptying job writes), where my local version ended at any byte with bit 7 set, and the page gets its old protection back. Four more runs on that code: 4 of 4 in the world, three of them with exits, one without needing any.