Access violation at image+0x4dac5bf before the world (a pool link with a garbage offset) #339

Open
opened 2026-11-27 12:53:12 +00:00 by alicans · 5 comments
alicans commented 2026-11-27 12:53:12 +00:00 (Migrated from github.com)
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by alicans on 2026-11-27T12:53:12Z.


What went wrong

On an M4 Pro, 24 GB, macOS 15.8.2, Series S, windowed, many of my runs that get near the world end at image+0x4dac5bf, 69 to 281 s in (render frame 1408 to 2112). I've seen it in 9 runs so far:

  • on every main I've tried, from 49e7c64 to c5d7f4d0;
  • with and without my two local changes (a title-watchdog patch and sampled textures without their two most detailed levels);
  • the latest with neither of them, holding the watchdog with VICTORY_HOLD_BYTE=1471b6330:1 instead.

It does not look like memory pressure: in the latest run the macOS memory level was 31 to 37 % at the fault.

Each time 1 to 8 threads fault at the same instruction within a millisecond, reading an unmapped address. In every run the same two registers have the same shape:

run local changes threads rcx r8 read address
NV6 none 1 0x10830075b56bdcd0 0x10840074b56bdcd0 0x268769cd0
NV10 level change 3 0x8808027c4d6dd037 0x8809027b4d6dd037 0x201db1037
NV14 both 7 0x194201c3bb95cd00 0x194301c2bb95cd00 0x26fe10d00
NV16 both 6 0xc0020033c2be1c5a 0xc0030032c2be1c5a 0x27954dc5a
NV17 both 7 0x2bad00b9b533acd0 0x2bae00b8b533acd0 0x268eaacd0
NV22 both 8 0x00000001d6bb8680 0x00010000d6bb8680 0x28b814680
NV33 both 2 0x2252019e4254102b 0x2253019d4254102b 0x1fa90502b
NV34 both 7 0x238e0090fffefffe 0x238f008ffffefffe 0x2b3df3ffe
NV37 neither 7 0x18dc008e19324085 0x18dd008d19324085 0x1cc570085

Builds: main 49e7c64 (NV6) through c5d7f4d0 (NV37); NV33 and NV34 also had #263, #253, #264, #278 (and #304 in NV34), NV37 had #296 and #301.

  • r8 is always rcx + 0x0000ffff00000000: the top 16 bits go up by one and the next 16 go down by one. That looks like a lock-free pool head: a tag, a count and a 32-bit offset in one 64-bit word.
  • The low 32 bits are the offset. The read address ends in the same low 12 bits as the offset, so the offset is used to form the address. The offsets are garbage: 0xfffefffe, 0x4254102b (a float, 53.0...), 0x19324085.

My reading is that something wrote over a freed block's link while it sat on the title's free list, and the next pop followed it. Two host things could do that, and I can't tell them apart from here:

  • GPU work that still writes title memory after the title was told it was done (fences signalled early);
  • host copies written back over memory the title has reused. The #301 trace shows copies at 3 to 5 times the distinct title memory under them at the same point in the load.

If there is a switch that catches a host or GPU write into a range the title has freed, I can run it.

Steps to reproduce

run-native.sh-equivalent run: --console series-s, windowed, VICTORY_HOLD_BYTE=1471b6330:1, no other switches, warm or cold shader cache. Many runs that get near the end of the story load fault here; some get past it.

Mac, macOS version and commit

M4 Pro, 24 GB, macOS 15.8.2. Latest: main c5d7f4d0 + #296 + #301; seen on every main from 49e7c64.

Output or log

VIctory: unhandled exception 0xc0000005 at image+0x4dac5bf [0, 1cc570085, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6646821867 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/339). Originally posted by [alicans](https://github.com/alicans) on 2026-11-27T12:53:12Z. --- ### What went wrong On an M4 Pro, 24 GB, macOS 15.8.2, Series S, windowed, many of my runs that get near the world end at `image+0x4dac5bf`, 69 to 281 s in (render frame 1408 to 2112). I've seen it in 9 runs so far: - on every main I've tried, from `49e7c64` to `c5d7f4d0`; - with and without my two local changes (a title-watchdog patch and sampled textures without their two most detailed levels); - the latest with neither of them, holding the watchdog with `VICTORY_HOLD_BYTE=1471b6330:1` instead. It does not look like memory pressure: in the latest run the macOS memory level was 31 to 37 % at the fault. Each time 1 to 8 threads fault at the same instruction within a millisecond, reading an unmapped address. In every run the same two registers have the same shape: | run | local changes | threads | rcx | r8 | read address | |---|---|---|---|---|---| | NV6 | none | 1 | `0x10830075b56bdcd0` | `0x10840074b56bdcd0` | `0x268769cd0` | | NV10 | level change | 3 | `0x8808027c4d6dd037` | `0x8809027b4d6dd037` | `0x201db1037` | | NV14 | both | 7 | `0x194201c3bb95cd00` | `0x194301c2bb95cd00` | `0x26fe10d00` | | NV16 | both | 6 | `0xc0020033c2be1c5a` | `0xc0030032c2be1c5a` | `0x27954dc5a` | | NV17 | both | 7 | `0x2bad00b9b533acd0` | `0x2bae00b8b533acd0` | `0x268eaacd0` | | NV22 | both | 8 | `0x00000001d6bb8680` | `0x00010000d6bb8680` | `0x28b814680` | | NV33 | both | 2 | `0x2252019e4254102b` | `0x2253019d4254102b` | `0x1fa90502b` | | NV34 | both | 7 | `0x238e0090fffefffe` | `0x238f008ffffefffe` | `0x2b3df3ffe` | | NV37 | neither | 7 | `0x18dc008e19324085` | `0x18dd008d19324085` | `0x1cc570085` | Builds: main `49e7c64` (NV6) through `c5d7f4d0` (NV37); NV33 and NV34 also had #263, #253, #264, #278 (and #304 in NV34), NV37 had #296 and #301. - `r8` is always `rcx + 0x0000ffff00000000`: the top 16 bits go up by one and the next 16 go down by one. That looks like a lock-free pool head: a tag, a count and a 32-bit offset in one 64-bit word. - The low 32 bits are the offset. The read address ends in the same low 12 bits as the offset, so the offset is used to form the address. The offsets are garbage: `0xfffefffe`, `0x4254102b` (a float, 53.0...), `0x19324085`. My reading is that something wrote over a freed block's link while it sat on the title's free list, and the next pop followed it. Two host things could do that, and I can't tell them apart from here: - GPU work that still writes title memory after the title was told it was done (fences signalled early); - host copies written back over memory the title has reused. The #301 trace shows copies at 3 to 5 times the distinct title memory under them at the same point in the load. If there is a switch that catches a host or GPU write into a range the title has freed, I can run it. ### Steps to reproduce run-native.sh-equivalent run: `--console series-s`, windowed, `VICTORY_HOLD_BYTE=1471b6330:1`, no other switches, warm or cold shader cache. Many runs that get near the end of the story load fault here; some get past it. ### Mac, macOS version and commit M4 Pro, 24 GB, macOS 15.8.2. Latest: main c5d7f4d0 + #296 + #301; seen on every main from 49e7c64. ### Output or log ```text VIctory: unhandled exception 0xc0000005 at image+0x4dac5bf [0, 1cc570085, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ```
AnastasisKon commented 2026-11-27 13:31:09 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-27T13:31:09Z.


/claim

I'll build the diagnostic switch: VICTORY_TRACE_FREED=1 records every range XMemAlloc/XMemAllocDefault hands out and XMemFree/XMemFreeDefault returns (the header's size, so page-level ranges), and every host write into title memory — the texture copy-back path, and every writable mapping handed to the GPU through resolve — is checked against the freed table and logged with both ranges and a serial. One honest scope limit up front: the title hooks its own sub-allocator (hooks()[1]), so frees the title's own pools do internally are invisible to this — it catches the XMem-granularity class, both your host-copy and GPU-write hypotheses at that granularity. PR within the day; you run it.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7219578158 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/339#issuecomment-7219578158). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-27T13:31:09Z. --- /claim I'll build the diagnostic switch: VICTORY_TRACE_FREED=1 records every range XMemAlloc/XMemAllocDefault hands out and XMemFree/XMemFreeDefault returns (the header's size, so page-level ranges), and every host write into title memory — the texture copy-back path, and every writable mapping handed to the GPU through resolve — is checked against the freed table and logged with both ranges and a serial. One honest scope limit up front: the title hooks its own sub-allocator (hooks()[1]), so frees the title's own pools do internally are invisible to this — it catches the XMem-granularity class, both your host-copy and GPU-write hypotheses at that granularity. PR within the day; you run it.
github-actions[bot] commented 2026-11-27 13:31:20 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T13:31:20Z.


Claimed by @AnastasisKon. Open a draft pull request with Refs #339 in its description within 24 hours, or the claim expires.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7219582617 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/339#issuecomment-7219582617). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-27T13:31:20Z. --- Claimed by @AnastasisKon. Open a draft pull request with `Refs #339` in its description within 24 hours, or the claim expires.
alicans commented 2026-11-27 19:14:34 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by alicans on 2026-11-27T19:14:34Z.


One more run with the fault, this time with VICTORY_TRACE_FREED=1 (main 582670f1, so #378 is in; copy-back off):

run local changes threads rcx r8 read address
NV43 watchdog patch, UAV level fix 7 0x063b07edb3c748f0 0x063c07ecb3c748f0 0x2695f48f0
  • It faulted at +73 s, after render frame 1472, before the world. The memory level was 44 %.
  • The trace logged no write into freed title memory before the fault (no line at all in the run).
  • Switches: VICTORY_TEXTURE_DROP_TOP_MIP=1, VICTORY_METAL_RESIDENCY_SETS=heap, VICTORY_DEPTH_TWINS=0, VICTORY_HOLD_BYTE=1471b6330:1.
  • The run just before it, NV42, had the same build and switches. It reached the world and ran the full 300 s without the fault.

So the freed-range check does not see what goes wrong here, at least not at XMem granularity. Is there a trace you would like run next for the title's own pools?

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7226331568 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/339#issuecomment-7226331568). Originally posted by [alicans](https://github.com/alicans) on 2026-11-27T19:14:34Z. --- One more run with the fault, this time with `VICTORY_TRACE_FREED=1` (main `582670f1`, so #378 is in; copy-back off): | run | local changes | threads | rcx | r8 | read address | |---|---|---|---|---|---| | NV43 | watchdog patch, UAV level fix | 7 | `0x063b07edb3c748f0` | `0x063c07ecb3c748f0` | `0x2695f48f0` | - It faulted at +73 s, after render frame 1472, before the world. The memory level was 44 %. - The trace logged no write into freed title memory before the fault (no line at all in the run). - Switches: `VICTORY_TEXTURE_DROP_TOP_MIP=1`, `VICTORY_METAL_RESIDENCY_SETS=heap`, `VICTORY_DEPTH_TWINS=0`, `VICTORY_HOLD_BYTE=1471b6330:1`. - The run just before it, NV42, had the same build and switches. It reached the world and ran the full 300 s without the fault. So the freed-range check does not see what goes wrong here, at least not at XMem granularity. Is there a trace you would like run next for the title's own pools?
LakshanSivakumar commented 2026-11-28 00:35:24 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-28T00:35:24Z.


Thanks for the nine runs and the careful tables. I am sorry nobody from me answered sooner.

I do not know the cause yet. Your reading looks right to me: the low 32 bits are an offset, the offset is garbage, and something wrote over the link of a freed block. I cannot tell yet if the writer is the GPU, a host copy or the title itself.

Two things on main since your last build. #513 fixes heap buffer views that kept pointing at pages the title had freed and then reused, so a shader could read and write memory that now belonged to something else. That is one way a free-list link could be overwritten, so it may help, but I have not tested it against your fault. Also VICTORY_TRACE_FREED=1 is on main now (thanks to AnastasisKon). As you saw, it only catches XMem-sized ranges, so your NV43 result does not rule out a write inside the title's own pools.

Could you run once more on main a6a58361, same setup as NV43 with VICTORY_TRACE_FREED=1, and tell me if it still faults and when? If it does not fault, that is useful but not proof, because you only saw it in some runs. I have not run it myself.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7231033190 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/339#issuecomment-7231033190). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-28T00:35:24Z. --- Thanks for the nine runs and the careful tables. I am sorry nobody from me answered sooner. I do not know the cause yet. Your reading looks right to me: the low 32 bits are an offset, the offset is garbage, and something wrote over the link of a freed block. I cannot tell yet if the writer is the GPU, a host copy or the title itself. Two things on main since your last build. #513 fixes heap buffer views that kept pointing at pages the title had freed and then reused, so a shader could read and write memory that now belonged to something else. That is one way a free-list link could be overwritten, so it may help, but I have not tested it against your fault. Also `VICTORY_TRACE_FREED=1` is on main now (thanks to AnastasisKon). As you saw, it only catches XMem-sized ranges, so your NV43 result does not rule out a write inside the title's own pools. Could you run once more on main a6a58361, same setup as NV43 with `VICTORY_TRACE_FREED=1`, and tell me if it still faults and when? If it does not fault, that is useful but not proof, because you only saw it in some runs. I have not run it myself.
github-actions[bot] commented 2026-11-29 08:50:52 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-29T08:50:52Z.


The claim by @AnastasisKon has expired: no pull request referenced it within 24 hours. This issue is free to claim.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7253370788 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/339#issuecomment-7253370788). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T08:50:52Z. --- The claim by @AnastasisKon has expired: no pull request referenced it within 24 hours. This issue is free to claim.
Sign in to join this conversation.
No labels
No milestone
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.

Reference
LakshanSivakumar/Native-Victory-macOS#339
No description provided.