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

Abierto
#42,280 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
12/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
cpp, linux

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
C++
Estrellas
34.4k
Forks
1.9k
Merge medio
1 d 23 h
PR fusionados (30 d)
166

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/WSL

Todos los issues de microsoft/WSL

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.