Skip to content

ProjectScarlett: 30 s main-thread watchdog (exe+0x23CF683) at the story intro from cross-queue label-wait deadlocks #215

Description

@NickStallman

On an RTX 5090 (NVIDIA 595.99.02, GE-Proton11-14, main ac4f099 with #212 and #214), ProjectScarlett gets past setup and the story loading screens. It reaches Game State: Game Running: mission 0x98c85f2a, SRL fbk_stry000_FBK_STRY000_INTRO in Prestream. The first world frames render, but at 10–21 s each, and the title then deliberately writes to address 0 at game_scarlett_master.exe+0x23CF683. It happened in all three runs, at frames 18579, 9569 and 4190. This is the same RVA reported in #16 (comment by ReverendOzmund).

What the crash is

It is the title's 30-second main-thread heartbeat watchdog, not a GPU label timeout. "GPU Loc Sig" is only its tag.

  • The watchdog thread is at 0x2215A60 (trampoline 0x2215EA0). It runs Sleep(1000) with QPC and compares the heartbeat at 0x71B6338, which 0x22159F0 writes from the main loop. After 30 unchanged ticks it calls the callback at [0x71B6348] (0x2215C33), then executes mov [0],0. It tolerates a single sleep longer than 2 s, so a debugger pause doesn't trip it.
  • The tag: the per-frame function 0x23CF6A0 installs 0x23CF620 as that callback while it waits for the render thread. The callback decodes "GPU Loc Sig", logs it and writes 0x4D8BD421 to [0].
  • The minidumps (drive_t/*.dmp):
    • The crashing thread's last heartbeat was 29.7 s before the sleep.
    • The main thread is blocked in that render-thread wait (0x23CF735).
    • The render thread is in WaitForSingleObject(INFINITE) on its job handles.

Why frames take 10–30 s

The queues deadlock across each other, and each deadlock is broken only by the memory-wait release in commands/memory_wait.rs (5 s).

  1. TuxBox's own texture publication wait (device/placement.rs, "wait for this batch's texture publication"):
    • The graphics queue is held on this wait.
    • Behind it sits a batch that writes a label a compute queue is waiting for (stalled label … waited by list … type 2 queue … written by list … type 0 queue).
    • Skipping the publication waits in an experiment removed this class of stall entirely.
  2. The remaining cycle: 8 of 10 stalled labels report no submitted or rejected list writes it.
    • Compute queues are held on title labels whose writer list hasn't been submitted.
    • The title can't submit it, because its main and render threads are waiting for GPU progress.
    • On console, a queue wait doesn't hold up the CPU side. Here the per-queue serial wait worker and the cross-queue holds turn it into a CPU↔GPU cycle.
    • With a 1.5 s release instead of 5 s, frames still take 17–21 s and the watchdog still fires.

Prior art

  • xcl ran into both of these:
    • [c4396e2] Every timeout came with the producer queue waiting on xcl's own inserted wait (its texture page-mapping fence). Skipping that wait took CPU releases from 4 to 0–1 per run.
    • [8a5643f] It bridges Write64BitValue / Wait64BitValueX through per-address ID3D12Fences, with GPU Signal at the write and GPU Wait at the wait. It does not poll on the CPU, and it detects and breaks cross-queue cycles when a fence is signalled. It also has bounded CPU and GPU waits, "so a genuinely hung GPU cycle never triggers" the 30 s hang.
  • ztrx 35b054e hit the same 30 s watchdog in this title, from more than 1,200 synchronous pipeline creates on the first world frame. That one is a separate cause, already mitigated here by preparing shaders before launch.

I'm starting on a port of the label-bridging approach and will link it here. Comments are welcome if the memory-wait design has constraints I should keep.

Activity

  1. ReverendOzmund commented on Nov 26, 2026

    @ReverendOzmund
    Contributor

    Same crash on an RTX 3080 Ti (driver 620.70.06, Proton Experimental, main around 8ce988d plus a local slot 80 patch): Game Running, mission 0x98c85f2a set at frame 2,351, then the write to address 0 at +0x23CF683 at frame 2,358, 4m29s in. 10 GPU memory waits had been released after 5 s by then. On another launch, the title wrote to 0 from +0x2215C35, inside the watchdog thread you found, during System Init at frame 0. That launch had stalled before any frame was presented. Happy to test the label-bridging work on Ampere.

    One thing worth checking before porting: xcl is GPL-2.0-only, and TuxBox is Apache-2.0. Reimplementing the per-address fence idea from its description is fine, but code ported from xcl would bring its licence with it.

  2. brcly commented on Nov 26, 2026

    @brcly
    Owner

    also suffering from the crash here. i believe its shader related, due to some empty or failed shaders.

    im gonna try and put effort into compilation times and translations today to bring down the gaps on nvidia from the 64 lane waves.

  3. NickStallman commented on Nov 26, 2026

    @NickStallman
    ContributorAuthor

    An update from more runs on an RTX 5090 (GE-Proton11-14), in case it helps narrow this down:

    The stalled labels do have a writer. The no submitted or rejected list writes it labels are written by an ordinary Write64BitValueBottomOfPipeX in a graphics list that the title records but submits late. explain() only sees lists at submit, and in one run the writer (order 45189) showed up 14 submissions after the compute wait (order 45175). The graphics side was held behind TuxBox's texture publication waits ("wait for this batch's texture publication" / "earlier texture publication"), which held::blocked only skips for the same reader fence and tick. My next experiment is to skip publication waits whose writer queue still has unreleased label waits.

    With fences per label (an experiment, not proposed): 0 cycles were detected. But each frame still released the per-frame label waits (target = frame counter, value 0) after 2 s, so frames took 14–26 s. The intro audio played over a black screen with a few lights, and the watchdog fired after 38 min.

    With #216 + #217 on main 773278a: no memory-wait releases and 20–30 fps throughout. But at Prestream Metadata the kernel logged an NVIDIA Xid 13 (SKEDCHECK36_DEPENDENCE_COUNTER_UNDERFLOW, a compute launch fault) and vkd3d-proton reported VK_ERROR_DEVICE_LOST. The watchdog fired 35 s later, because the render thread was spinning on a label the lost device would never write. So the same crash address can also hide a device loss. I haven't established that #216 causes it; I'll rerun with VKD3D_CONFIG=breadcrumbs to find the dispatch.

    On shaders: in these stalls the null usage intervals showed no stand-in pipeline bound. The world frames do skip about 1,000 draws and dispatches per frame with pipeline has no paged descriptor layout (guest callers 0x2951ba, 0x248cbc1), which looks like a descriptor-paging limit rather than a translation failure.

    On licence (thanks @ReverendOzmund): agreed. The experiment was written from a description of the idea. A review found two functions structurally too close to xcl's; those were rewritten from scratch, and nothing from it is proposed upstream.

  4. ReverendOzmund commented on Nov 26, 2026

    @ReverendOzmund
    Contributor

    @NickStallman opened #223 so the "no paged descriptor layout" skip says which case it is: no recorded root, a root that indexes the heap directly, or a root that didn't parse. If your world-frame skips turn out to be direct-indexed, I'm happy to work on a paged path for them, since translated shaders already carry tb_heap_map.

  5. NickStallman commented on Nov 27, 2026

    @NickStallman
    ContributorAuthor

    A measured breakdown of the intro stall. It points away from a label-wait deadlock and towards texture publication volume.

    Run: RTX 5090, driver 620.70.10, GE-Proton11-14, game files on local disk. The build is main at e76ff6a plus #235 (since merged), with a local diagnostic probe. The probe isn't proposed for merging. #216's newly translatable compute programs were replaced with no-ops to get past the #232 hang; that hang still fired later, at 1,055 s.

    The 5 s releases are not dead waits. The probe recorded 53 released label waits between 668 and 792 s, all before the Xid. In every one, the graphics queue holding the label's writer kept moving: at least 3 operations, median 1,378, during the 5 s. It started a median 3,611 operations behind the waiting queue. When each stall began, the graphics queue was waiting on:

    • "wait for an earlier texture publication": 39 stalls;
    • "wait for another queue's texture reads": 13 stalls;
    • nothing: 1 stall.

    So the writer is late because the graphics queue is slow, not because something holds it.

    What makes it slow. These are totals over 354 s of the world phase:

    total per unit
    submits through placement 581
    publication jobs 319 667 MiB written back per job
    bytes written back to guest memory 208 GiB
    NtWriteVirtualMemory calls 31.1 M about 97k per job, 6.8 KiB each
    publication time 511 s 1.6 s per job
    submit time under the device-wide submissions lock 255 s 0.44 s per submit

    The slowest publications each read back 269–278 placed textures, 755–762 MB, and took 2.2–3.2 s. Frames come every 11–18 s.

    Why so many textures (read from code, not traced to specific draws). When a root's tables can't describe an access, Recording::sample_tables falls back to sample_heap() (commands/recording.rs:685-699). The batch then samples the whole resource heap. DescriptorMap::gather (placement/descriptors.rs:138-148) puts every placed texture with a UAV view in that heap into the batch's writes, so each batch reads back and republishes about 275 textures, whether the programs write them or not.

    Next steps:

    • Measure how much of the publication time is the per-run write call, with a direct-copy experiment.
    • Look at counting a heap as written only when the bound program has writable heap accesses. The translator knows that statically.

    #277 and #279 don't change the write set.

  6. NickStallman commented on Nov 27, 2026

    @NickStallman
    ContributorAuthor

    A note now that this is closed: #290 removes the wineserver cost of each write, but not the stall itself, as its description says. On an RTX 5090 with #290 in place, world frames still took about 12 s, because each batch still reads back and republishes about 650 MiB. Any root that samples the whole heap counts every UAV-viewed placed texture as written. That's the volume problem in my comment above.

    I'm working on narrowing that write set to the textures a pipeline can actually write. In this title nearly every image store goes through a fixed descriptor-table slot. I'll open it as a PR with measurements when it's ready, and reference this issue from there rather than reopening it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions