[WSLg / D3D12] `ID3D12PipelineState::GetCachedBlob()` and `ID3D12PipelineLibrary::StorePipeline()` crash with "double free or corruption"

Aperta
#42,280 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
12/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
cpp, linux

Direzione di ricerca

The repro is pso_cache_probe.cpp, which calls GetCachedBlob() on a compute pipeline state and then StorePipeline() on a pipeline library created with CreatePipelineLibrary(nullptr, 0, ...). Build it with the g++ line in the issue and run it under gdb or with AddressSanitizer to get a backtrace at the abort. Done means both calls return instead of aborting, or CheckFeatureSupport stops reporting SINGLE_PSO and LIBRARY. The crash is likely in the WSL D3D12 translation layer (libd3d12.so), which may not be in this repository, so confirm where the backtrace lands before changing anything.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

emailed-logs GPU wsl2
Windows Version

Windows 11 25H2, build 26200.9711

WSL Version

WSL 3.0.5.0, kernel 6.18.58.1-1, WSLg 1.0.79

Are you using WSL 1, WSL 2, or WSLC?
  • WSL 2
  • WSL 1
  • WSLC
Kernel Version

6.18.58.1-1

Distro Version

Ubuntu 24.04

Other Software
  • Direct3D (WSL) 1.611.1-81528511 (libd3d12.so/libd3d12core.so dated 2023-10-20), DXCore 10.0.26100.1

  • NVIDIA RTX PRO 500 Blackwell Generation Laptop GPU, driver 32.0.15.9595

  • Ubuntu 24.04, DirectX-Headers from the distribution

Repro Steps

pso_cache_probe.cpp (compute shader: any DXIL compute shader with an
embedded root signature; ours is compiled with
dxc -T cs_6_0 -E cs_main -Fh depthcopy_cs_main.h -Vn g_cs_main):

#include <wsl/winadapter.h>
#include <directx/d3d12.h>
#include <directx/dxcore.h>
#include <dxguids/dxguids.h>
#include <cstdio>
#include <cstring>
#include "depthcopy_cs_main.h"   // const unsigned char g_cs_main[]

int main() {
    IDXCoreAdapterFactory *f; IDXCoreAdapterList *l; IDXCoreAdapter *ad = nullptr;
    const GUID attr[] = {DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS};
    DXCoreCreateAdapterFactory(IID_PPV_ARGS(&f));
    f->CreateAdapterList(1, attr, IID_PPV_ARGS(&l));
    for (uint32_t i = 0; i < l->GetAdapterCount() && !ad; ++i) {
        char desc[256] = {}; IDXCoreAdapter *a;
        l->GetAdapter(i, IID_PPV_ARGS(&a));
        a->GetProperty(DXCoreAdapterProperty::DriverDescription, sizeof(desc), desc);
        if (strstr(desc, "NVIDIA")) ad = a;
    }
    ID3D12Device1 *dev;  D3D12CreateDevice(ad, D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&dev));
    ID3D12RootSignature *rs; dev->CreateRootSignature(0, g_cs_main, sizeof(g_cs_main), IID_PPV_ARGS(&rs));
    D3D12_COMPUTE_PIPELINE_STATE_DESC d = {}; d.pRootSignature = rs; d.CS = {g_cs_main, sizeof(g_cs_main)};
    ID3D12PipelineState *p;  dev->CreateComputePipelineState(&d, IID_PPV_ARGS(&p));   // S_OK
    ID3DBlob *blob;
    printf("GetCachedBlob...\n"); fflush(stdout);
    p->GetCachedBlob(&blob);                       // aborts: double free or corruption (!prev)
    ID3D12PipelineLibrary *lib; dev->CreatePipelineLibrary(nullptr, 0, IID_PPV_ARGS(&lib));
    lib->StorePipeline(L"test", p);                // also aborts (seen separately)
    return 0;
}
g++ -O1 -g $(pkg-config --cflags DirectX-Headers) -o pso_cache_probe pso_cache_probe.cpp \
    $(pkg-config --libs DirectX-Headers) -L/usr/lib/wsl/lib -Wl,-rpath,/usr/lib/wsl/lib -ld3d12 -ldxcore
./pso_cache_probe
Expected Behavior

As on Windows with the same GPU and driver: GetCachedBlob() returns a blob that
can be passed back in D3D12_*_PIPELINE_STATE_DESC::CachedPSO, and
StorePipeline() returns S_OK. Alternatively, CheckFeatureSupport should not
report SINGLE_PSO/LIBRARY when they are unsupported.

Actual Behavior
adapter: NVIDIA RTX PRO 500 Blackwell Generation Laptop GPU
CreateDevice: 0x00000000
CreateRootSignature: 0x00000000
CreateComputePipelineState: 0x00000000
GetCachedBlob: ...
double free or corruption (!prev)
Aborted (core dumped)

StorePipeline() on an empty library created with CreatePipelineLibrary(NULL, 0, ...)
aborts the same way (a LoadGraphicsPipeline() miss before it returns
E_INVALIDARG as expected).

Diagnostic Logs

No response

Lingua principale
C++
Stelle
34.4k
Fork
1.9k
Merge medio
1g 23h
PR unite (30g)
166

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/WSL

Tutte le issue di microsoft/WSL

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.