fix(gpu): shut down Streamline before ExitProcess to prevent DLSS-G teardown null deref #413
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/413"
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 Androtim/MiniVI. Originally posted by Androtim on 2026-12-04T00:30:17Z.
Root Cause
With DLSS Frame Generation (
VICTORY_FRAMEGEN=1) enabled, process exit paths (first-start warm-up auto-restart, settings menu restart, and window close) went throughending::end_process, which invokedExitProcess(code)directly without shutting down Streamline (slShutdownwas previously only called inupscaler-check).Disassembly and symbol analysis of
nvngx_dlssg.dll(NGX 310.9.16) at crash offset+0x16c40identifies the failure mechanism:+0x16b10..+0x16fa1isDLSSGInstanceManager::ReleaseInstance, called byNVSDK_NGX_D3D12_ReleaseFeature(+0x13ba0).+0x16c40,mov rcx, [r15 + rax*8 + 0x8]indexes thestd::unordered_mapbucket array (r15 = [r14 + 0x60]).ExitProcessrunsDLL_PROCESS_DETACHwithout a priorslShutdown(),nvngx_dlssg.dll's staticDLSSGInstanceManagerdestructor frees its bucket vector (r15 = nullptr) beforesl.dlss_g.dlltears down and invokesNVSDK_NGX_D3D12_ReleaseFeature, causing a0xc0000005null pointer dereference.Changes
Streamline Pre-Exit Teardown
streamline::shutdown_for_exit()(idempotentshutdown_once()withVICTORY_STREAMLINE_TEARDOWN=0escape hatch) invoked fromending::end_processbeforeExitProcess(code)on clean/restart exits.slShutdown()under the Streamline call lock.Gate 2 Audit Hardening
ending.rs):code > 255, such asDXGI_ERROR_DEVICE_REMOVED0x887A_0005) or whenhost_made().is_some_and(|h| unsafe { h.device.GetDeviceRemovedReason() }.is_err()),end_processskipsshutdown_for_exit()andExitProcessand callsTerminateProcess(GetCurrentProcess(), code)directly aftersave_pipeline_cache().host.presenter/host.submittedduringhost::fail(), avoidsDLL_PROCESS_DETACH, and preserves the exact exit code.code <= 255with a healthy device andVICTORY_EXIT_WAIT_MS > 0) continue to use boundedshutdown_for_exit()+ExitProcess(code).host.rs,streamline.rs):drop_presenter_with_settlewithdrop_presenter_before_shutdown(settle, before_drop), which locksself.presenterfirst (preservingself.presenter-> StreamlineCALLSlock order), runsdisable_framegen_for_shutdown()while the proxied swap chain is still alive and noPresent/ResizeBuffersis in flight, settles GPU work without holdingCALLS, and drops the presenter.frame_token(sl, frame)inside thecalls()lock after theSHUTTING_DOWNcheck and movedmark(abi::PRESENT_START)beforedrop(calls)inpresent_begins().resizing()onSHUTTING_DOWNboth before and undercalls().end_processserialization (ending.rs):ENDING_THREAD: AtomicU32single-owner claim: concurrent callers from another thread park indefinitely so the first caller completessave_pipeline_cache()->shutdown_for_exit()->ExitProcess(code)cleanly; same-thread re-entry terminates immediately viaTerminateProcess(GetCurrentProcess(), code).slShutdown(streamline.rs):crate::host::host()withcrate::host::host_made()inshutdown_once()and added early return indevice_made()whenSHUTTING_DOWNis set or!SL_INITIALIZED.SL_INITIALIZED: AtomicBoolset only afterslInitreturns0and gatedshutdown_once()on it.Verification
cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu -- streamline(23 passed)cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu -- ending(25 passed, including exit-mode selection andENDING_THREADsingle-owner/re-entry tests)cargo +1.98.1-x86_64-pc-windows-gnu check --workspace(clean)Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-04T00:32:20Z.
Triage (
8762b54d, CIIN_PROGRESS):+180/-43acrossending.rs,host.rs,host/menu.rs,streamline.rs,docs/dlss.md, zero opt-in toggles): setsENDING/SHUTTING_DOWN, releasespresenterlock beforeend_process, drops the proxied swap chain, and callsslShutdown()prior toExitProcessto preventnvngx_dlssg.dllDLL_PROCESS_DETACHnull derefs.#282) (specifically checkingshutdown_for_exitvspresent/record/reaperlock ordering and non-DLSS/AMD/Intel no-op path) + Gate 3 live DLSS-G exit & F1/warmup restart verification.