Skip to content

startup-runtime: null read after the user privilege queries (about 75 s) #1160

Done

Description

@rasptum

Problem

With tools/startup/run.ps1 -Render -FakeUser -GpuMirror -ContinueAsserts 5000 on an NVIDIA GeForce RTX 3060 (driver 32.0.15.9636, Windows 10 22H2 19045.6466, debug layer off), one console executable stops at 74.2 s and again at 75.1 s (two runs, same instruction) with a second-chance access violation inside the executable: a read at address 0x68 through an object whose first pointer is null.

What precedes it in both runs, from stderr.txt and files.txt:

  • the executable's debug output reports that its save service was created;
  • a burst of gaming-runtime calls on the user interface: method 19 once, then method 20 with a series of small ids (they look like privilege checks), all answered 0x0 by X2W_FAKE_USER;
  • repeated QueryApiImpl calls for a second provider (answered 0x0);
  • 4 socket opens refused by offline mode.

The run in #1135 (RDNA4, Windows 11) reached its 150 s timeout, so this may depend on timing, on an answer that leaves an output argument unset, or on the two local changes needed to get this far here (drive mapping and a capped view heap, see the linked issues).

Where to start

  • Log the output arguments of user-interface methods 19 and 20 and of the second provider's methods; an S_OK with an untouched out-pointer is the first suspect.
  • X2W_TRAP_DUMP on the faulting object and --stop-first-chance 1 give the caller chain.

Done when

The call whose answer leaves the null pointer is identified and answered, or the cause is shown to be outside the runtime proxy and split into a narrower issue.

Context: docs/startup-runtime.md (#1135). Do not attach game files, dumps or logs that contain addresses or names from an executable; describe results in terms of the component tested.

AI-assisted (Claude Code).

Activity

  1. rasptum commented on Nov 24, 2026

    @rasptum
    ContributorAuthor

    Claiming this. First step is logging the output arguments of the user-interface calls that precede the fault and getting the caller chain with --stop-first-chance 1. I will post the answer that leaves the pointer unset, or narrow the issue if the cause is elsewhere.

    AI-assisted (Claude Code).

  2. triggered02 commented on Nov 24, 2026

    @triggered02
    Contributor

    A second adapter reaches a null object in the same phase, at a different offset — possibly a second instance rather than the same one.

    Measured with tools/startup/run.ps1 -Render -FakeUser -GpuMirror -ContinueAsserts 1000 -InputScript 4@70 on main at 857d9731: NVIDIA GeForce GTX 1660 SUPER (driver 32.0.16.1074), Windows 11 build 26200, release build of the stand-ins. Two runs from a cold start stopped at the same instruction at 82.7 s and 86.9 s.

    What precedes it matches the sequence you describe: the save service is created, the gaming-runtime user-interface calls (method 19 once, then method 20 with small ids) are answered by X2W_FAKE_USER, a second provider's QueryApiImpl calls are answered, and the offline mode refuses socket opens. Then the executable reads through a null object.

    Our stop is a read at 0x10, not 0x68: a predicate test on a flags byte at offset 0x10 of an object whose pointer is null. The pointer arrives with no desktop call failing — I added a hook that logs every failed HRESULT returned through the device stand-in's forwarding paths (the per-slot probes stop after their first few calls, so a late failure was invisible), and in a full 90-second run the only forwarded call that failed was CreateCommandSignature, which the stand-in already turns into a placeholder and which is not on this path.

    The null instead comes from inside the executable: a factory routine returns NULL after its own internal check fails, and its caller passes that NULL straight to the routine that then asserts (the run steps over the assert as a soft assert and faults on the second-chance pass). So the first suspect is whatever the factory is waiting for — consistent with your "an S_OK with an untouched out-pointer" hypothesis, but one step further back: something the factory queries returned a value it treats as "not ready" rather than an outright failure.

    Two details that may help distinguish adapters: with the view-heap fallback of #1159 and s_setprio treated as a hint (#1241) the run presents 1,852 frames at 28.5 fps with 5,378 translated draws and 4/4 pipelines before it stops, so this is not a translation or descriptor problem. And textures uploaded 0 in the render totals at the same time, which suggests the texture-upload path never runs before this stop; whether that is a cause or another consequence of the same missing state is not established.

    An unrelated observation from the same runs, in case it matters to #1147 or #1160: X2W_FAKE_USER answers every user-interface method with 0x0, including methods where the desktop expects the out-argument filled. That is exactly the shape you flagged, and our runs cannot tell whether the factory above is reading one of those unfilled outputs.

  3. rasptum commented on Nov 24, 2026

    @rasptum
    ContributorAuthor

    Progress, and a correction to this issue's framing: on Windows 10 the null read is not caused by the user privilege queries. They just precede it.

    Cause, measured on the RTX 3060 / Windows 10 19045 setup above:

    • The executable's root signatures set CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED | SAMPLER_HEAP_DIRECTLY_INDEXED (0xC00).
    • The in-box Windows 10 D3D12 runtime predates shader model 6.6, so D3D12SerializeVersionedRootSignature (reached through the d3d12_xs stand-in) returns E_INVALIDARG.
    • The executable doesn't check that result, its pipeline object stays null, and the first use is the read at 0x68 about 75 s in.
    • When serialization is retried without those two bits (X2W_D3D12_PERMISSIVE=1), the same run continues past that point to the first-run menus. That's the only change.

    Fix, two parts, in one commit: f32b22f2 on rasptum/startup/win10-root-flags, on current main.

    1. The serializer retries without 0xC00 and remembers, per returned blob, which bits it removed.
    2. The recording device gives those bits back in the copy kept for shader translation. Without that, gfx2hlsl lays out the user SGPRs one short, and the glyph pipelines fail with s_load through s10 holding None.

    PR to follow once I've added a source-built check for the retry.

    On the GTX 1660 SUPER report above: Windows 11's runtime accepts these flags, so that stop is probably a second, different cause in the same phase rather than this one.

    AI-assisted (Claude Code).

  4. triggered02 commented on Nov 24, 2026

    @triggered02
    Contributor

    Taking this, since it is the wall every run hits before the loading screen and I have a reproducible setup (offline stand-ins, view-heap clamp on main, 4/4 pipelines translated, run stops at the same instruction every time).

    Plan, following the issue's own starting point: log the output arguments of the user-interface methods 19 and 20 and of the second provider's \QueryApiImpl\ calls, so an \S_OK\ with an untouched out-pointer is visible rather than guessed. Then dump the faulting object and walk its callers to name which factory returned NULL, and report whether the missing answer is a privilege value or a provider that never resolves.

    One measured fact that narrows this: the stop is not adapter-specific — an RTX 3060 (your report) and a GTX 1660 SUPER (mine) stop at the same place, at ~74 s and ~85 s respectively, with the same 0x10-offset read through a NULL object and no desktop call failing. I will describe results in terms of the components tested and not attach dumps or logs containing executable addresses.

    AI-assisted (Claude Code).

  5. triggered02 commented on Nov 24, 2026

    @triggered02
    Contributor

    Follow-up with one correction to this issue's hypothesis, and a question about which way to take the fix.

    Correction: the two user-interface methods this issue suspects do write their outputs. With X2W_FAKE_USER=1 both are implemented and fill the out-arguments:

    • method 19 (XUserGetAgeGroup) writes 3 (adult) to its out pointer;
    • method 20 (XUserCheckPrivilege) writes has = true and deny reason = 0, and returns S_OK.

    So "an S_OK with an untouched out-pointer" is not what happens on those two paths. Both write, and both were answered that way in every failing run I have. That removes the first suspect and points at whatever the factory gates on downstream of them.

    What I can see of the mechanism (reported as component behaviour, no addresses attached): the NULL is produced by the executable's own code, not by the runtime. A factory routine returns NULL after an internal boolean check fails; its caller passes that NULL straight into a helper that tests it and takes the soft-assert path, and the fault is a second-chance read through the NULL object when the assert is stepped over. Nothing on the desktop side failed in the same runs — I had every failed HRESULT through the device stand-in's forwarding paths logged, and the only one was CreateCommandSignature (0x80070057), which is turned into a placeholder and is not on this path.

    Independent of adapter: RTX 3060 stops at ~74 s, GTX 1660 SUPER at ~85 s, same instruction, same null object, so this is not a timing or GPU quirk. It also survives all the view-heap and pipeline changes (clamp on main, 4/4 pipelines translated, 5,378 translated draws before the stop).

    The question: which follow-up do you want, and is this already known?

    1. Is that factory gating on an answer the stand-ins could plausibly supply — a privilege, age group, store or save value — or is it engine-internal state that only gets set once the earlier streaming path is fixed?
    2. If it is worth pinning down, should the follow-up be (a) an instrumentation PR that logs the factory's input queries as they happen, so a run names the gate instead of inferring it, or (b) an attempt to answer whichever query turns out to be missing?

    I have no working x64 disassembler locally, so I would rather instrument the stop than guess at the call target. If you would prefer this stays with you and only wants the measurements, that is fine too — say so and I will stop here rather than open a PR.

    The log path also stops before the loading screen, so anything you can tell me about what the factory is expected to have by then shortens this a lot.

  6. R0Y00 commented on Nov 24, 2026

    @R0Y00
    Owner

    Thanks for confirming both methods write their documented outputs. Please continue with observation first. A small source-built trace of the public stand-in calls, their return codes and whether an output was populated would be useful. On the two affected runs, compare the last successful provider call and the first downstream failure before the assertion. Keep build identifiers and a short call sequence, and leave addresses and raw traces local. If no provider call fails, record that result and keep the factory condition open. The current evidence does not establish a missing privilege or save response.

  7. triggered02 commented on Nov 24, 2026

    @triggered02
    Contributor

    Observation done, as asked. Short answer: no provider call fails in the whole run, and the last thing before the assertion is a successful-but-not-S_OK poll that repeats thousands of times.

    How the trace was built. An opt-in switch (X2W_TRACE_API=1) in the proxy dispatch logs one line per provider call: provider id, method slot, return code, whether the answer came from the stand-in or the real runtime, and which of the pointer-shaped arguments was written (compared by snapshotting arguments 1-8 before the call and re-reading after, so a write is seen rather than assumed). It is a small source-built change; I have not opened a PR for it because you asked for observation first — say the word and it goes up.

    Result over a full run to the assertion (GTX 1660 SUPER, Windows 11 build 26200, 11,478 provider calls):

    • Zero calls returned a failing HRESULT (0x80000000 or above). Not one, across every provider.
    • The dominant tail is a two-call loop, repeated to the end:
    x2w-api 37e56907::slot2  -> 0x00000001 real  out=none     (S_FALSE, real runtime)
    x2w-api 37e56907::slot15 -> 0x00000000 local out=none     (stand-in)
    

    37e56907::slot2 returned 0x00000001 5,587 times and 37e56907::slot15 was answered locally 5,511 times; the last ~20 calls before the stop are that pair alternating. So the assertion is reached immediately after a poll that succeeded with S_FALSE, not after any failure.

    One hypothesis, explicitly not established: if the factory gates on hr == S_OK, a S_FALSE (0x00000001) answers "not ready" while still being a success code, which would produce exactly the NULL-returning bool you would expect from the observed NULL. That fits the evidence and no failing call contradicts it, but the trace alone cannot show the comparison.

    One shape worth naming, also not confirmed: 30 calls answered by the real runtime returned S_OK with no sampled argument changed (073b7dcb::slot29, ::slot6, ::slot3). That is the "success without an output" pattern, but a call with no out-argument among arguments 1-8 cannot be judged by this method, so I am not calling those empty.

    Caveat on the method: out=none means none of the pointer-shaped arguments among 1-8 changed. Calls that pass handles and sizes rather than pointers cannot be assessed this way, which is why 5k successful calls show out=none and it is not itself a finding.

    Per your instruction: since no provider call fails, I am recording that result and keeping the factory condition open. The question I would like answered to go further: is 37e56907::slot2 expected to return S_FALSE permanently once its queue is empty, and does the caller treat S_FALSE as success? If S_FALSE is the gate, the fix is on our side (answer S_OK or the expected item) rather than engine-internal.

    Addresses and raw traces stayed local; only provider ids, slots, codes and the call sequence are above.

  8. R0Y00 commented on Nov 24, 2026

    @R0Y00
    Owner

    Thanks for the follow-up. The repeated S_FALSE/S_OK pair narrows the trace, and the return codes alone do not establish which condition causes the null. Please keep the real provider result intact. The next useful evidence is a typed, source-built poll that distinguishes ready with an item, empty/not ready, and failure, plus the documented return and output contract if you can identify the interface. A small optional logging PR is welcome if it records declared outputs only and avoids reading arbitrary pointer-shaped arguments. Keep the factory diagnosis open until a call and the consuming condition can be tied together.

  9. triggered02 commented on Nov 24, 2026

    @triggered02
    Contributor

    The optional logging PR you welcomed is up: #1324, X2W_TRACE_API=1, one line per provider call with the return code, whether the answer came from the stand-in or the real runtime, and which declared output argument was written. It reads only the outputs in a small contract table (user add result, id, guest flag, state, gamertag buffer and used count, age group, privilege result and deny reason, connectivity hint); a slot with no declared contract reports out=? and nothing is read. The real provider result is left intact — nothing overrides or rewrites it.

    One correction to my previous comment. My "5,555 successes with no sampled argument changed" figure should be withdrawn. With declared outputs, the connectivity hint reports unchanged 3,400 times simply because its four words are constant, so a repeat call leaves identical bytes. "Unchanged" is therefore not evidence that an output was skipped, and that number cannot be read as "an S_OK with an untouched out-pointer". The new line distinguishes the cases per call instead of leaving it to be inferred.

    Interface identification, which you asked for: the poll pair is provider 37e56907-2f10-41e8-b72f-36edb185331a, interface bf2346b2-39af-4658-b5ea-44713c7e83b3.

    • That provider is the connectivity family in our stand-in: slot 15 is answered locally as a connectivity hint with level none, cost unknown, initialized set — the "stack initialized, no connectivity" answer already in the code.
    • Slot 2 is not covered by the stand-in at all, so it passes through to the real runtime and returns S_FALSE (0x00000001) there — 5,587 times in the last run, immediately before the assertion.

    So the typed poll you asked for is the next step and the trace now gives it what it needs: a fixture that asks this interface for connectivity and distinguishes ready-with-item / empty-not-ready / failure, comparing what the real runtime returns for slot 2 against what our hint claims for slot 15.

    What I still cannot state from the code is what slot 2 is meant to mean. If you can name the interface method, I will pin the documented return and output values into the fixture rather than inferring them from the code, which is the difference between "we saw S_FALSE" and "S_FALSE here means X".

    Keeping the factory diagnosis open, as instructed: the trace ties the last call before the assertion to a S_FALSE poll, but has not tied that call to the consuming condition inside the factory.

  10. triggered02 commented on Nov 24, 2026

    @triggered02
    Contributor

    One experiment on the gate, since it is cheap and it changed the number: reporting full internet connectivity instead of "none" (level 3 in the hint words, everything else unchanged) moved the stop from 84-86 s to 106.36 s, at the same instruction, with the same NULL object and the same 0x10 read.

    So connectivity state is a factor in how fast the run gets there, but it is not the gate: the assertion still fires, just later. That fits the S_FALSE poll loop being a wait rather than the trigger, and it means answering "connected" alone will not get past this.

    I have reverted the experiment; nothing is committed. If it is useful I can keep it as a switch (for example X2W_CONNECTIVITY=none|local|internet) so the two timings stay comparable across runs, but I did not want to add a knob with no confirmed meaning.

  11. R0Y00 commented on Nov 24, 2026

    @R0Y00
    Owner

    Thanks for reverting the timing experiment. The same failure at a later time is useful evidence. Please keep the connectivity override out of the diagnostic PR. Once the typed trace is available, prioritize the return that feeds the null-consuming branch and record its expected success/failure and output contract in a source-built control. A poll-loop frequency or a changed startup time alone cannot identify that producer.

  12. triggered02 commented on Nov 24, 2026

    @triggered02
    Contributor

    Before building the typed trace, an observation that changes this issue's premise: the null-consuming branch no longer fires on current main.

    On c4966c64 (which includes #1294 gpu/startup-slot57-blend-hookup) the title now runs past the old stop repeatedly:

    run old behaviour (fac6a522) current main
    1 access violation at +0x6eb759 after 84–86 s, NULL object, 0x10 read ran to the 200 s cap, 5,130 frames, no crash
    2 same ran to 210 s, 6/6 pipelines, 69,008 translated draws
    3 same ran to 278 s, 8,064 frames @ 29 fps, no crash
    4 same ran to 330 s, reached the first-run wizard, no crash

    And it is not merely surviving: the flow now reaches the UI. ACCOUNT PICKER → CONTINUE → UI TEXT SIZE → NAVIGATION EXPERIENCE → LEGAL NOTICES, with correct text rendering (the blend hookup in #1294 is what fixed the glyphs), navigable with A. So the factory that returned NULL either has been fixed or is no longer reached, and the S_FALSE connectivity poll pair that preceded it is not followed by the assertion any more.

    Two points for the plan you set:

    1. The connectivity override stays out of any PR — it was an experiment only and is reverted; the merged trace PR (startup: trace declared provider outputs behind an opt-in switch #1324) contains no override.
    2. A source-built control for "the return that feeds the null-consuming branch" needs that branch to be reachable. In my runs it is not, so I cannot record a contract for a producer I can no longer observe. If the branch still reproduces for you or on another configuration, tell me what differs and I will build the control there; otherwise the honest options are to close this as fixed by the runtime work, or keep it open as "not reproducible on main at c4966c64" until someone sees it again.

    I would rather flag that than build a fixture that exercises a branch the current build never takes.

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