LEGO Batman: Legacy of the Dark Knight (PPSA16833): sceKernelReleaseDirectMemory of a ~336 MiB render-target block waits forever in GuestAllocationsRequireUnpinned while the GPU is idle (pin abort, or RenderThread 120 s timeout) #7408
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 boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-18T04:56:18Z.
LEGO Batman frees a block of about 336 MiB that holds its 2560x1440 render targets at level loads and when the player switches between Performance and Fidelity mode. The free never completes.
sceKernelReleaseDirectMemorysits inGuestAllocationsRequireUnpinned→WaitForLeasesAndImports, and every AGC driver thread is idle meanwhile, so no GPU work is left to drop the lease. Whichever timer runs out first ends the title:APS5_PIN_WAIT_MS(60 s):guest allocation … is still pinned by GPU work or an import (waited 60000 ms for the lease)APS5_PIN_WAIT_MS=180000: Unreal's own watchdog fires first,GameThread timed out waiting for RenderThread after 120.00 secs4 of 5 desktop runs today ended this way, on two
mainbases; the fifth died earlier on an unrelated error. Not every level load triggers it: runs 3 and 4 each passed one load before the one that hung. It also happened on an AMD V620 (RADV), so it doesn't depend on the vendor. This looks like the same lease mechanism as #6453, but there the waits end after 15–20 s. Here the wait doesn't end, even with nothing in flight.Details and logs
Title: LEGO Batman: Legacy of the Dark Knight (PPSA16833 v01.010.000)
Setup: CachyOS, RTX 4090 (NVIDIA 615.78.08), Release. Game files and shader cache on an NVMe SSD for the last two runs. The
2626e5ee7builds aremainplus #7123 only (the guest frame-chain fix, without which LEGO's stack walker crashes first). The5d9dcc42dbuilds also carried LEGO's start-up fixes that were unmerged then and are inmainnow (sampler heap,sceCoredumpConfigDumpMode, the web-browser dialog); the desktop one had #7123 too, the V620 one did not.APS5_PIN_WAIT_MS5d9dcc42dguest allocation 0x115d000000+0x15600000 is still pinned … (waited 60000 ms)5d9dcc42dguest allocation 0x115ce00000+0x15000000 is still pinned … (waited 180000 ms)¹2626e5ee7GameThread timed out waiting for RenderThread after 120.00 secs2626e5ee7+APS5_NO_RESIDENT_LINEAR=1GameThread timed out waiting for RenderThread after 120.00 secs5d9dcc42dguest allocation 0x116ca00000+0x14e00000 is still pinned … (60 s)¹ A live
gcoresnapshot paused run 2 for ~5 min during the wait, so its 180 s is not a clean measurement. The snapshot itself is the evidence below.Where the title waits. This is the same stack in the run-2 snapshot (taken during the freeze) and in the cores of runs 3 and 4. It comes from the same guest call site,
app.elf+0x5b564c:In all three dumps the AGC driver threads are idle in condition-variable waits:
Driver::run(both queues),DrawPipeline::run,ReleaseThreadMainand theRegistrationPreparePoolworkers. Nothing is recording or executing. So the lease that keeps the range pinned belongs to something that isn't running and won't release it on its own.WaitForLeasesAndImportsdrops the cached address space first, so that holder is ruled out.What is being freed. The freed block contains the title's 2560x1440 render targets (the log has
StorageTexture/Texturelines at0x115d350000,0x1167cd0000,0x116a890000and0x1170290000inside run 1's range). Before run 1's abort, the log also shows the precursor[gpu] leased allocation 0x1171600000+0xc00000 still pinned after 8 recorder syncs, inside the same range. On2626e5ee7the same warning appears several times per run, at 0.3–2 MiB ranges.Ruled out:
88ee39183: run 4 has them off, same resultI haven't identified which object holds the lease. With a pointer to the right counter or holder list, I can add a local diagnostic and rerun. The cores are available locally if a specific value is useful. They contain game memory, so I can't attach them.
Related: #6453 (whole-registry leases make guest unmaps wait; Onimusha, stalls that end), #6182 (oversized registrations kept pinned), #4846 (a 60 s lease wait at exit, closed), #7123.
Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T05:09:15Z.
I traced the current
mainwaiter against the stack.WaitForLeasesAndImportscan dropSpaces().current, finish through the newest lease batch (or drain the recorder), and retire overlapping live imports (plus parked imports on Windows). The issue's idle-thread snapshot does not distinguish which path keeps making progress, or whether an import is the remaining holder.Could you capture a small local-only counter trace for one failing unmap, without attaching the core or game memory? The useful values are the pinned range's
use_countbefore and after each callback; whether the callback dropped the address-space cache, finished a lease serial, drained the recorder, or retired an overlapping import;newestLeaseSerialversusfinishedLeaseSerial; and whetherRecorder::Active()->Idle()was true. A per-wait summary is enough. If the range stays pinned after the cache is dropped and all overlapping imports are retired, while the recorder is idle and its lease serial is finished, that would point us toward a retained CPU-side lease owner; if the serial keeps advancing, it would show new work is still acquiring leases during the mutation.That should identify a specific holder/path before changing the lease contract, while keeping the captured data limited to counters and addresses already present in the report.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T05:45:56Z.
I found an existing, closely matching fix in open PR #6182. Its regression test reproduces an unmap stuck on a registered range split across 64 MiB host-import windows: each window import owns the same whole registered range, but the waiter retires imports by window overlap, so disjoint windows can keep the range pinned after the overlapping import is retired. The reported 336 MiB block is larger than that default window, and the symptom after recorder syncs is consistent with this path.
I cannot confirm from the report alone that LEGO’s render-target block is registered and served by multiple host-import windows. Could you check whether those addresses have multiple
HostImport::rangesowners / whether window imports are active during the stuck unmap? If so, #6182 appears to cover the underlying fix and this would not need a duplicate PR. If the block is not host-imported, the requested per-waituse_countand lease-serial counters would still help identify the remaining owner.Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-18T06:57:32Z.
@MarcZX100 here is the counter trace you asked for, plus something the memory trace turned up along the way.
Counters. The range stays pinned after the cache is dropped and the overlapping import is retired. The recorder is idle and its lease serial is finished. So by your test, this points to a retained CPU-side lease owner, not new work acquiring leases. The serial never advances during the wait.
A release-ordering problem.
sceKernelReleaseDirectMemoryfrees the physical range before it unmaps the views (DirectMemoryFree, thenUnmapDirectMemoryViews). While the unmap waits on this lease, the title allocates the freed pages again and maps them as its command-buffer heap. Then a host import of the old render-target block is created again, still covering those pages. On a fast disk this happens on almost every boot, and the title stops on garbage in its own command buffers. Swapping the two calls removes that crash here (2 of 2 boots past the menu). I'll open that as a separate PR.Details and logs
Same title (PPSA16833),
main2626e5ee7+ #7123, plus local-only counters (APS5_PIN_DIAG) inGuestAllocationsRequireUnpinned(pinned range anduse_countper round) and inWaitForLeasesAndImports(which path each call took,newestLeaseSerial/finishedLeaseSerial,Recorder::Active()->Idle(), whether the active recorder is the lease recorder). The counters are rate-limited to the first 3 rounds and then one line per second.One failing unmap, start to end: the title releases a 62 MiB slice
0x116aa00000+0x3e00000of the render-target block0x1158c00000+0x15c00000.use_countafterA second run with the ordering fix shows the same pattern on the same slice (
0x116a800000+0x3e00000): cache drop, one serial finish (35405 → 35461) with an import retired, thenuse_count=3with the serial at 35461/35461, the recorder idle and no overlapping import, released after 190,932 rounds / 6,884 ms. In runs 3 and 4 of the report the same wait never ended (RenderThread timeout).So
use_count3 means the registry plus two owners. Neither is the address-space cache (dropped once, not repopulated: no latercache_droppath) or a lease batch tracked by the serial. One more thing from the import trace: just before the wait ended, a newhost import of 0x1158c00000+0x15c00000was created, covering the slice being unmapped.Release ordering (
APS5_TRACE_MEMORY=1 APS5_TRACE_HOST_IMPORT=1, same run):The title's command buffer at
0x10f6ff0630lies in the new mapping of0x97400000…. In the core, that page holds 16-bit image-like rows where packets should be, and those bytes exist nowhere else in host memory. That fits GPU writes through the stale import. All 7,487 file reads of the run (APR, AIO,pread,read) were traced, and none landed within 1 MiB of it.On an SSD this crash (or the same corruption caught as
truncated PM4 packet/sceAgcSetShRegIndirectPatchSetAddress: unexpected packet type) hit 8 of 9 boots, on builds from5d9dcc42dto2626e5ee7. On an HDD it hit 0 of 2 tonight on2626e5ee7, and none of about 20 earlier runs. With the two calls swapped, the same SSD setup passed the menu in 2 of 2 runs, one of them into gameplay.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T14:41:43Z.
Thanks for the counter trace and the release-order comparison. That is a distinct, concrete issue from the stalled lease itself: freeing the physical pages before unmapping the guest views lets the title reuse those pages while an old host import still aliases them. The reported repeated SSD failures versus two passes after swapping the order make this a strong candidate for a focused fix. I’ll avoid a parallel implementation while you prepare the separate PR; please link it here when it is open so I can review the change and its regression coverage.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T20:07:36Z.
Thanks for opening #7448 and adding the release-order regression. The report now supports a distinct consequence of the long lease: the physical range can be reused while old views still exist, and the ordering change keeps it allocated until those views are unmapped. I reviewed the checked-release precheck and left a concurrency question on #7448 about two simultaneous checked releases using the same view snapshot; that case should be clarified or covered before treating the PR as complete. The original long wait itself remains a separate issue.
Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-18T20:20:11Z.
@MarcZX100 the release-order fix is up as #7448 (unmap the views first, then free; a regression test that fails on
main). For the lease wait itself I'll test #6182 on the same title next and report whether the waits go away.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-18T20:54:01Z.
@MarcZX100 results for #6182 on the same title, on current
mainfb9a1eb8f+ #7448 + the local counters, one run each, same route (into gameplay, then Performance → Fidelity):2f540fa6d)use_count=3with the recorder idle and the serial finished for 1,076 roundsSo window imports do cover LEGO's render-target block (the 64 MiB
host importentries inside the pinned range), and #6182's path applies. But on currentmainthe long wait didn't reproduce without #6182 either: on2626e5ee7the same pattern lasted 6.9 s, or never ended (the RenderThread timeouts in the report). Something in the ~300 commits since then shortens it;fd301c78a(releasing settle-retired imports after the overlap block of a pin wait) looks like the most likely candidate. With one run each I can't attribute the 113 vs 313 ms difference to #6182. I'll keep the counters in my LEGO builds, and post again if a multi-second wait shows up on currentmain.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T06:52:25Z.
#7448 (
a70080967) now unmaps the views before the range goes back to the physical allocator, so a longGuestAllocationsRequireUnpinnedwait no longer lets another allocation take pages that are still mapped. Could you retry the title on current main and say whether the 336 MiB release still hangs at level load or on the Performance/Fidelity switch? If it's gone we'll close this.Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-20T11:16:02Z.
@oneandonlydean retried on current
main35fa2bdd8(contains #7448). LEGO Batman: Legacy of the Dark Knight (PPSA16833), Linux, RTX 4090, plainmainwith no local patches:still pinned by GPU workabort and no RenderThread timeout. The log has 7[gpu] leased allocation … still pinned after 8 recorder syncsnotices, each one cleared on its own.mainplus #7963 loaded straight into the snow mountain from a save, also with no hang.mainloaded into the snow mountain again and played there for several minutes, with no hang either.So the 336 MiB release no longer hangs here. Fine to close from my side. Three sessions in all; if it comes back on a longer play session I'll reopen with a log.
Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T12:22:20Z.
Thanks for the retries on current
main. The 336 MiB release no longer hangs across the level load, the Fidelity switch or a few minutes of play, which matches #7448 (a700809679), now onmain. Closing as fixed; please reopen with a log if it comes back on a longer session.