DXGI interfaces are released before their last use in Generic::getVendorId

Aperta Adatta ai principianti
#120 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
86/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp

Direzione di ricerca

Inizia in source/platforms/sl.chi/generic.cpp, in Generic::getVendorId, intorno alle righe 349-367, e analizza la convenzione WRL ComPtr esistente. Mantieni la ownership delle interfacce DXGI acquisite fino ai loro utilizzi finali, preservando i controlli HRESULT e il comportamento in caso di errore. Valida con il focused lifetime harness oppure compilando la translation unit modificata con MSVC.

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

Descrizione

Problem

Generic::getVendorId releases both acquired COM interfaces before using them:

IDXGIDevice* dxgiDevice{};
if (SUCCEEDED(((IUnknown*)m_typelessDevice)->QueryInterface(&dxgiDevice)))
{
    dxgiDevice->Release();
    IDXGIAdapter* adapter{};
    if (SUCCEEDED(dxgiDevice->GetAdapter(&adapter)))
    {
        adapter->Release();
        DXGI_ADAPTER_DESC desc;
        if (SUCCEEDED(adapter->GetDesc(&desc)))

Source: generic.cpp at e8aaa6e. The same pattern is present on current main.

An outstanding reference to the original device does not guarantee that a separately acquired interface wrapper remains alive. COM permits independently managed tear-off interfaces; the returned pointer must remain owned until its final use. See Microsoft's reference-counting guidance.

This permits use-after-release at dxgiDevice->GetAdapter and independently at adapter->GetDesc, even if conventional native implementations happen to retain those objects internally.

Proposed fix

Keep both acquired references until scope exit using the existing WRL ComPtr convention. This preserves the HRESULT checks, return values, and unchanged output on failure, while releasing each reference on all exits.

A focused fix is available in northaxosky/Streamline commit 2e83322: one file, five insertions and six deletions. I attempted to submit it as a PR, but this repository currently has pull requests disabled.

Validation and limits

The modified translation unit compiled with MSVC. A local source-extracted lifetime harness exercises the success/error paths and independently reference-counted interface test doubles; retaining the interfaces removes its lifetime violations. This is a focused ownership check, not a full COM conformance or SDK integration test.

A full SDK build was not completed in this environment. Investigation began after a RenderDoc-enabled D3D11 application encountered an exception during Streamline device registration, but exact attribution of that application exception to this function has not been established. This report stands on the source-level ownership defect, not a claimed reproduction of that particular crash. No application binaries, captures, or crash dumps are attached.

Lingua principale
C
Stelle
1.4k
Fork
174
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

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 NVIDIA-RTX/Streamline

Tutte le issue di NVIDIA-RTX/Streamline

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.