acphal: since #527, ProjectScarlett crashes at game init (access violation in memcpy, frame 0) #554
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 brcly/TuxBox. Originally posted by 1093i3511 on 2026-11-29T22:51:48Z.
Since #527, ProjectScarlett crashes before the first frame on my machine, every time. cc @csj0oe
Setup: RX 6600 (RADV, Mesa 26.3.1), Linux 7.3.6, GE-Proton11-14,
main39463ea5, warm caches, default settings.What happens: about 50 s after launch the game ends with exit 5. Its crash report says
Game State: Game Init,Frame: 0. The log has an access violation insidememcpy, called from the game's own code:It happened in 2 of 2 runs, with and without
TUXBOX_SKIP_SHADERS. Builds onfd636d09got through init every time.Bisection. I reverted one group of runtime commits from
fd636d09..39463ea5at a time, built, and ran the game for 90 s each:fa548ac1+55a6f4fd(acphal, #527)fa548ac1alonee0540c64+e7d7f455(xcrdapi)So the crash comes with
55a6f4fd("acphal: follow the 26100 apu.h heap, flag and alignment rules").fa548ac1builds on it, so I couldn't revert55a6f4fdalone.One more difference in the log: with both acphal commits reverted,
TuxBox xapu: software Opus connection readyappears. With them, it doesn't appear before the crash. So APU setup seems to fail first.A guess, not checked. #527 says it wasn't run against a title, so this may be the first launch with it. Its description lists three behaviours ProjectScarlett could hit:
ApuCreateHeapnow allocates the default heaps, so the title's ownApuCreateHeapthen returnsAPU_E_HEAP_ALREADY_ALLOCATED. If the title or another provider (xapu, for example) touches the APU before creating its heap, the title would be left with the 64 MB default.ApuCreateHeapreturns that error instead ofS_OK.ApuAllocrejects an alignment of 0, below 4, or not a power of two, and unknown flags, withE_INVALIDARGinstead of clamping.If the title doesn't check one of these results, it would copy into a null or too-small allocation, which matches the
memcpy. My bet is the first one, since xapu's line is missing, but acphal doesn't log these calls, so I can't tell which. I can run a build with logging aroundApuCreateHeapandApuAllocif that helps.Imported from brcly/TuxBox. Originally posted by Kayotic1337 on 2026-11-29T23:02:18Z.
Same crash here on an RX 9070 XT (
1002:7550, RDNA 4, RADV / Mesa 26.3.1, GE-Proton11-14, Linux 7.3.6), so it isn't specific to one card. Same backtrace:VCRUNTIME140.dll + 0x1989fromgame_scarlett_master.exe + 0x43AED60/+ 0x43AD941,Game Init, frame 0, exit 5 after about 55 s, 2 of 2 runs onmainf360038d.Bisection on
main.git bisect --first-parentbetween2d6dc338(good) and6bab5478(bad), each step built and run for up to 120 s:f85be3829a266c1a(#526)9e087199051bdf79(#527, squashed)Reverting only #527. On
mainthe change landed as the single commit051bdf79, so it can be reverted on its own.f360038dwith just that revert runs past init and is still running at 120 s.Imported from brcly/TuxBox. Originally posted by 3kynox on 2026-11-29T23:04:34Z.
The same crash here on an NVIDIA card, and the same remedy.
main97f21fadwith local changes inruntime/d3d12only, shaders prepared, ProjectScarlett 1.0.2.1 offline.AcpHal.dll: 2 runs of 2 end atGame State: Game Init, frame 0, 110 s and 32 s after launch, with the backtrace above (VCRUNTIME140.dll + 0x1989fromgame_scarlett_master.exe + 0x43AED60, then+0x43AD941,+0x43A657A,+0x25A4E47).AcpHal.dllbuilt from the tree before #527 (03aeb2a7): the title gets through init. Three minutes after launch it has presented 7,217 frames and is still running, and the log hasTuxBox xapu: software Opus connection ready, which the two crashing runs did not reach.So the acphal change is the cause here as well. I haven't looked at which of the three behaviours it is.
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T23:20:53Z.
Same crash and the same first bad commit here (RTX 5090, 620.70.10, GE-Proton11-14; I filed it as #556 without finding this issue, sorry, and am closing that). I can add what fails. With a local patch that only logs the APU calls, on
mainf482572a:So it isn't the default heaps, a second
ApuCreateHeap, or the alignment and flag checks: the non-cached heap is too small. 0x5780 rounded up to that alignment plus 0x222e00 is 0x228600, and the heap has 0x226e00, so it's 0x1800 bytes short. Before #527 the two heaps were one region. That the failedApuAllocis what the title then copies into is inferred from the order, not traced.Rounding the non-cached size up to 64 KiB (0x230000) gets plain
f482572athrough init; it was still running when my 2-minute limit ended it. That's draft #557, with a unit test of those calls. The rule is a guess: I don't know whether the console's heap is larger than asked for, or keeps the XMA contexts elsewhere. @csj0oe, please take it or replace it; reverting #527 works too, as shown above.Imported from brcly/TuxBox. Originally posted by 1093i3511 on 2026-11-29T23:34:30Z.
Thanks, all three. @NickStallman's log settles it: the non-cached heap is 0x1800 bytes short, so my guess about the default heaps was wrong. I'll run #557 on the RX 6600 (RDNA 2) and report whether the title gets through init and further with it.
Meanwhile, with both acphal commits reverted on
39463ea5, the title gets through init here too, with the xapu Opus line back. In default mode it then reached the world after about 35 minutes and ended on the title's watchdog.Imported from brcly/TuxBox. Originally posted by glovepost on 2026-11-29T23:37:49Z.
Confirmed this reproduces identically on
--graphics-profile series-s(xbox.device_type = 6/ Lockhart) as well (RTX 2070 SUPER10de:1e84, driver620.73.04, GE-Proton11-14: 2/2 runs exit with code 5 at ~64–68s with the same stackVCRUNTIME140.dll + 0x1989←game_scarlett_master.exe + 0x43AED60←+0x43AD941←+0x43A657A←+0x25A4E47).Disassembly trace of
game_scarlett_master.exeThis directly confirms @NickStallman's inferred chain from the failed
ApuAllocto the crash:+0x43ad924calls+0x25a8750(returns0xff=255 MiBon Series S /ConsoleMode=0x60vs0x1c7=455 MiBon Series X), shifts left by 20, and passes a hardcodednonCachedSizeInBytes = 0x226e00toApuCreateHeap(+0x43ad933) on both Series X and Series S.+0x43aec73callsAcpHalAllocateShapeContextswithnumXmaContexts = 0x15e(350→0x5780bytes,0x5800after0x800alignment).+0x43aecf7storesNULLat[rsp+0x30]and calls+0x43a6110, which invokesApuAlloc(out, NULL, 0x222e00, 0x800, 2)without checking itsHRESULTreturn value, soE_OUTOFMEMORYleaves[rsp+0x30] == NULL.+0x43aed18loadsr15 = [rsp+0x30](NULL) and+0x43aed5bcallsVCRUNTIME140.dll!memset(NULL, 0, 0x1700)(theVCRUNTIME140.dll + 0x1989AV with return address+0x43aed60ismemset, notmemcpy).Heap sizing note (re: #557)
The budget arithmetic gives a useful clue about the console behavior:
nonCachedSizeInBytes:0x226e00ApuAlloc:0x222e00nonCachedSizeInBytes:0x226e00 - 0x222e00 = 0x4000(16 KiB)AcpHalAllocateShapeContexts(xma=350):350 * 64 = 0x5780bytes (> 0x4000)Since
0x4000 < 0x5780, the title clearly did not include the SHAPE context table in itsnonCachedSizeInBytesbudget. That points to the console either allocating SHAPE contexts from a separate/system non-cached region rather than charging the title'snonCachedSizeInBytesheap, or adding the default ~1 MiB system/SHAPE reserve on top ofnonCachedSizeInBytesinstead of replacing it when non-zero.One caveat to keep in mind for #557: rounding
nonCachedSizeInBytesup to 64 KiB happens to add0x9200bytes for0x226e00(0x226e00 -> 0x230000), which covers0x5800here — but if a title passes an already 64 KiB-alignednonCachedSizeInBytesand then callsAcpHalAllocateShapeContexts+ApuAllocnear that size, 64 KiB rounding adds0bytes and would hit the sameE_OUTOFMEMORY. Keeping SHAPE contexts separate from the title'snonCachedSizeInBytesbudget (or adding the default reserve rather than rounding) would avoid that alignment-dependent edge case.Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T23:50:27Z.
@glovepost thanks, that settles the chain, and both corrections are right: it's a
memset, not a copy, and 64 KiB rounding is fragile. #557 now adds the default 1 MiB on top of a title's size instead; moving the contexts to a heap of their own would contradict the existing tests that count them in the non-cached heap. @1093i3511, if you were about to run #557, please take the new head: only the rounding version has run in the game so far.Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-30T04:12:45Z.
Fixed on main by #557, squashed as
70d7e137. The non-cached APU heap now gets the default heap's room on top of the size a title asks for, so the SHAPE contexts no longer squeeze out ProjectScarlett's own 0x222e00 block. Verified with a boot from main: the title gets through init, the xapu Opus connection comes up, and shaders compile. Thanks @1093i3511, @Kayotic1337, @3kynox, @NickStallman and @glovepost for the bisection, the call logs and the disassembly that pinned it down.