Skip to content

D2D DEBUG ERROR - Memory leaks detected #15306

@ianjoneill

Description

@ianjoneill

Windows Terminal version

main 10c6206

Windows build number

10.0.22621.1555

Other Software

No response

Steps to reproduce

  1. Open the terminal
  2. Close the terminal

Expected Behavior

No debug assertions get hit.

Actual Behavior

A debug assertion is hit - stating that there are memory leaks.

Debug Output:

An interface [000001A8656D9E28] was created but not released. Use 'dps 000001A8656D9DC8' to view its allocation stack.
Object type: ID2D1SolidColorBrush
	Color: r=1.00 g=1.00 b=1.00 a=1.00
	Outstanding reference count: 1

An interface [000001A8656D9B88] was created but not released. Use 'dps 000001A8656D9B28' to view its allocation stack.
Object type: ID2D1SolidColorBrush
	Color: r=1.00 g=1.00 b=1.00 a=1.00
	Outstanding reference count: 1

An interface [000001A865614C48] was created but not released. Use 'dps 000001A865614BE8' to view its allocation stack.
Object type: ID2D1DeviceContext
	Outstanding reference count: 1

An interface [000001A8656C4108] was created but not released. Use 'dps 000001A8656C40A8' to view its allocation stack.
Object type: ID2D1Factory
	Factory type: D2D1_FACTORY_TYPE_SINGLE_THREADED
	Outstanding reference count: 4

D2D DEBUG ERROR - Memory leaks detected.
(66cc.4b0): Break instruction exception - code 80000003 (first chance)
KERNELBASE!wil::details::DebugBreak+0x2:
00007ffa`470a7b02 cc              int     3

Allocation stack 1:

0:000> dps 000001A8656D9DC8
000001a8`656d9dc8  00007ff9`19f7b72d D2D1Debug3!DebugRenderTargetGenerated<ID2D1BitmapRenderTarget>::CreateSolidColorBrush+0xfd
000001a8`656d9dd0  00007ff9`0a56b1a6*** WARNING: Unable to verify checksum for F:\windows-terminal\src\cascadia\CascadiaPackage\bin\x64\Debug\AppX\Microsoft.Terminal.Control.dll
 Microsoft_Terminal_Control!Microsoft::Console::Render::Atlas::BackendD3D::_resizeGlyphAtlas+0x856 [F:\windows-terminal\src\renderer\atlas\BackendD3D.cpp @ 778]
000001a8`656d9dd8  00007ff9`0a56a754 Microsoft_Terminal_Control!Microsoft::Console::Render::Atlas::BackendD3D::_resetGlyphAtlas+0x264 [F:\windows-terminal\src\renderer\atlas\BackendD3D.cpp @ 707]
000001a8`656d9de0  00007ff9`0a56c072 Microsoft_Terminal_Control!Microsoft::Console::Render::Atlas::BackendD3D::_drawText+0x72 [F:\windows-terminal\src\renderer\atlas\BackendD3D.cpp @ 943]
000001a8`656d9de8  00007ff9`0a567252 Microsoft_Terminal_Control!Microsoft::Console::Render::Atlas::BackendD3D::Render+0x172 [F:\windows-terminal\src\renderer\atlas\BackendD3D.cpp @ 226]
000001a8`656d9df0  00007ff9`0a55599f Microsoft_Terminal_Control!Microsoft::Console::Render::Atlas::AtlasEngine::Present+0x1cf [F:\windows-terminal\src\renderer\atlas\AtlasEngine.r.cpp @ 56]
000001a8`656d9df8  00007ff9`0a09f4dd Microsoft_Terminal_Control!Microsoft::Console::Render::Renderer::_PaintFrameForEngine+0x72d [F:\windows-terminal\src\renderer\base\renderer.cpp @ 179]
000001a8`656d9e00  00007ff9`0a09c8c6 Microsoft_Terminal_Control!Microsoft::Console::Render::Renderer::PaintFrame+0xc6 [F:\windows-terminal\src\renderer\base\renderer.cpp @ 77]
000001a8`656d9e08  00007ff9`0a0ad02b Microsoft_Terminal_Control!Microsoft::Console::Render::RenderThread::_ThreadProc+0x11b [F:\windows-terminal\src\renderer\base\thread.cpp @ 214]
000001a8`656d9e10  00007ff9`0a0acef2 Microsoft_Terminal_Control!Microsoft::Console::Render::RenderThread::s_ThreadProc+0x32 [F:\windows-terminal\src\renderer\base\thread.cpp @ 160]
000001a8`656d9e18  00007ffa`487c269d KERNEL32!BaseThreadInitThunk+0x1d
000001a8`656d9e20  00007ffa`4958a9f8 ntdll!RtlUserThreadStart+0x28
000001a8`656d9e28  00007ff9`19fbf5b0 D2D1Debug3!DebugComObject<DebugSolidColorBrushGenerated<ID2D1SolidColorBrush> >::`vftable'
000001a8`656d9e30  00000000`00000001
000001a8`656d9e38  00080000`00000000
000001a8`656d9e40  000001a8`656ef1e0

Which is:

THROW_IF_FAILED(_d2dRenderTarget->CreateSolidColorBrush(&color, nullptr, _brush.put()));

Allocation stack 2:

0:000> dps 000001A8656D9B28
000001a8`656d9b28  00007ff9`19f7b72d D2D1Debug3!DebugRenderTargetGenerated<ID2D1BitmapRenderTarget>::CreateSolidColorBrush+0xfd
000001a8`656d9b30  00007ff9`0a56b0e4 Microsoft_Terminal_Control!Microsoft::Console::Render::Atlas::BackendD3D::_resizeGlyphAtlas+0x794 [F:\windows-terminal\src\renderer\atlas\BackendD3D.cpp @ 777]
000001a8`656d9b38  00007ff9`0a56a754 Microsoft_Terminal_Control!Microsoft::Console::Render::Atlas::BackendD3D::_resetGlyphAtlas+0x264 [F:\windows-terminal\src\renderer\atlas\BackendD3D.cpp @ 707]
000001a8`656d9b40  00007ff9`0a56c072 Microsoft_Terminal_Control!Microsoft::Console::Render::Atlas::BackendD3D::_drawText+0x72 [F:\windows-terminal\src\renderer\atlas\BackendD3D.cpp @ 943]
000001a8`656d9b48  00007ff9`0a567252 Microsoft_Terminal_Control!Microsoft::Console::Render::Atlas::BackendD3D::Render+0x172 [F:\windows-terminal\src\renderer\atlas\BackendD3D.cpp @ 226]
000001a8`656d9b50  00007ff9`0a55599f Microsoft_Terminal_Control!Microsoft::Console::Render::Atlas::AtlasEngine::Present+0x1cf [F:\windows-terminal\src\renderer\atlas\AtlasEngine.r.cpp @ 56]
000001a8`656d9b58  00007ff9`0a09f4dd Microsoft_Terminal_Control!Microsoft::Console::Render::Renderer::_PaintFrameForEngine+0x72d [F:\windows-terminal\src\renderer\base\renderer.cpp @ 179]
000001a8`656d9b60  00007ff9`0a09c8c6 Microsoft_Terminal_Control!Microsoft::Console::Render::Renderer::PaintFrame+0xc6 [F:\windows-terminal\src\renderer\base\renderer.cpp @ 77]
000001a8`656d9b68  00007ff9`0a0ad02b Microsoft_Terminal_Control!Microsoft::Console::Render::RenderThread::_ThreadProc+0x11b [F:\windows-terminal\src\renderer\base\thread.cpp @ 214]
000001a8`656d9b70  00007ff9`0a0acef2 Microsoft_Terminal_Control!Microsoft::Console::Render::RenderThread::s_ThreadProc+0x32 [F:\windows-terminal\src\renderer\base\thread.cpp @ 160]
000001a8`656d9b78  00007ffa`487c269d KERNEL32!BaseThreadInitThunk+0x1d
000001a8`656d9b80  00007ffa`4958a9f8 ntdll!RtlUserThreadStart+0x28
000001a8`656d9b88  00007ff9`19fbf5b0 D2D1Debug3!DebugComObject<DebugSolidColorBrushGenerated<ID2D1SolidColorBrush> >::`vftable'
000001a8`656d9b90  00000000`00000001
000001a8`656d9b98  00080000`00000000
000001a8`656d9ba0  000001a8`6568ff50

Which is:

THROW_IF_FAILED(_d2dRenderTarget->CreateSolidColorBrush(&color, nullptr, _emojiBrush.put()));

Allocation stack 3:

0:000> dps 000001A865614BE8
000001a8`65614be8  00007ff9`19f5a289 D2D1Debug3!DebugFactoryGenerated<ID2D1Factory1>::CreateDxgiSurfaceRenderTarget+0x259
000001a8`65614bf0  00007ff9`0a56acdb Microsoft_Terminal_Control!Microsoft::Console::Render::Atlas::BackendD3D::_resizeGlyphAtlas+0x38b [F:\windows-terminal\src\renderer\atlas\BackendD3D.cpp @ 749]
000001a8`65614bf8  00007ff9`0a56a754 Microsoft_Terminal_Control!Microsoft::Console::Render::Atlas::BackendD3D::_resetGlyphAtlas+0x264 [F:\windows-terminal\src\renderer\atlas\BackendD3D.cpp @ 707]
000001a8`65614c00  00007ff9`0a56c072 Microsoft_Terminal_Control!Microsoft::Console::Render::Atlas::BackendD3D::_drawText+0x72 [F:\windows-terminal\src\renderer\atlas\BackendD3D.cpp @ 943]
000001a8`65614c08  00007ff9`0a567252 Microsoft_Terminal_Control!Microsoft::Console::Render::Atlas::BackendD3D::Render+0x172 [F:\windows-terminal\src\renderer\atlas\BackendD3D.cpp @ 226]
000001a8`65614c10  00007ff9`0a55599f Microsoft_Terminal_Control!Microsoft::Console::Render::Atlas::AtlasEngine::Present+0x1cf [F:\windows-terminal\src\renderer\atlas\AtlasEngine.r.cpp @ 56]
000001a8`65614c18  00007ff9`0a09f4dd Microsoft_Terminal_Control!Microsoft::Console::Render::Renderer::_PaintFrameForEngine+0x72d [F:\windows-terminal\src\renderer\base\renderer.cpp @ 179]
000001a8`65614c20  00007ff9`0a09c8c6 Microsoft_Terminal_Control!Microsoft::Console::Render::Renderer::PaintFrame+0xc6 [F:\windows-terminal\src\renderer\base\renderer.cpp @ 77]
000001a8`65614c28  00007ff9`0a0ad02b Microsoft_Terminal_Control!Microsoft::Console::Render::RenderThread::_ThreadProc+0x11b [F:\windows-terminal\src\renderer\base\thread.cpp @ 214]
000001a8`65614c30  00007ff9`0a0acef2 Microsoft_Terminal_Control!Microsoft::Console::Render::RenderThread::s_ThreadProc+0x32 [F:\windows-terminal\src\renderer\base\thread.cpp @ 160]
000001a8`65614c38  00007ffa`487c269d KERNEL32!BaseThreadInitThunk+0x1d
000001a8`65614c40  00007ffa`4958a9f8 ntdll!RtlUserThreadStart+0x28
000001a8`65614c48  00007ff9`19fc1000 D2D1Debug3!DebugComObject<DebugDeviceContext6Generated<ID2D1DeviceContext6> >::`vftable'
000001a8`65614c50  00000000`00000000
000001a8`65614c58  0000ffff`00000000
000001a8`65614c60  00000000`00000002

Which is:

THROW_IF_FAILED(p.d2dFactory->CreateDxgiSurfaceRenderTarget(surface.get(), &props, reinterpret_cast<ID2D1RenderTarget**>(_d2dRenderTarget.addressof())));

Allocation stack 4:

0:000> dps 000001A8656C40A8
000001a8`656c40a8  00007ffa`42f3fef0 d2d1!D2D1CreateFactoryImpl+0xaf280
000001a8`656c40b0  00007ffa`42e91469 d2d1!D2D1CreateFactory+0xa9
000001a8`656c40b8  00007ff9`0a520cd1 Microsoft_Terminal_Control!Microsoft::Console::Render::Atlas::AtlasEngine::AtlasEngine+0xd1 [F:\windows-terminal\src\renderer\atlas\AtlasEngine.cpp @ 34]
000001a8`656c40c0  00007ff9`0a222c3e Microsoft_Terminal_Control!std::make_unique<Microsoft::Console::Render::Atlas::AtlasEngine,0>+0x4e [D:\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\memory @ 3393]
000001a8`656c40c8  00007ff9`0a1d6f7f Microsoft_Terminal_Control!winrt::Microsoft::Terminal::Control::implementation::ControlCore::Initialize+0x1ef [F:\windows-terminal\src\cascadia\TerminalControl\ControlCore.cpp @ 336]
000001a8`656c40d0  00007ff9`0a27dca7 Microsoft_Terminal_Control!winrt::impl::produce<winrt::Microsoft::Terminal::Control::implementation::ControlCore,winrt::Microsoft::Terminal::Control::IControlCore>::Initialize+0xa7 [F:\windows-terminal\src\cascadia\TerminalControl\Generated Files\winrt\Microsoft.Terminal.Control.h @ 2230]
000001a8`656c40d8  00007ff9`0a3f83f5 Microsoft_Terminal_Control!winrt::impl::consume_Microsoft_Terminal_Control_IControlCore<winrt::Microsoft::Terminal::Control::IControlCore>::Initialize+0x105 [F:\windows-terminal\src\cascadia\TerminalControl\Generated Files\winrt\Microsoft.Terminal.Control.h @ 91]
000001a8`656c40e0  00007ff9`0a3724dd Microsoft_Terminal_Control!winrt::Microsoft::Terminal::Control::implementation::TermControl::_InitializeTerminal+0x22d [F:\windows-terminal\src\cascadia\TerminalControl\TermControl.cpp @ 956]
000001a8`656c40e8  00007ff9`0a39bc89 Microsoft_Terminal_Control!`winrt::Microsoft::Terminal::Control::implementation::TermControl::TermControl'::`2'::<lambda_1>::operator()<winrt::Windows::Foundation::IInspectable,winrt::Windows::Foundation::IInspectable>+0x39 [F:\windows-terminal\src\cascadia\TerminalControl\TermControl.cpp @ 118]
000001a8`656c40f0  00007ff9`0a37a79c Microsoft_Terminal_Control!winrt::impl::delegate<winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable>,`winrt::Microsoft::Terminal::Control::implementation::TermControl::TermControl'::`2'::<lambda_1> >::Invoke+0x9c [F:\windows-terminal\src\cascadia\TerminalControl\Generated Files\winrt\Windows.Foundation.h @ 884]
000001a8`656c40f8  00007ffa`020dabad Windows_UI_Xaml!DirectUI::CEventSourceBase<DirectUI::IUntypedEventSource,Windows::Foundation::IEventHandler<IInspectable *>,IInspectable,IInspectable>::Raise+0x85 [onecoreuap\windows\dxaml\xcp\dxaml\lib\JoltClasses.h @ 275]
000001a8`656c4100  00007ffa`020daa93 Windows_UI_Xaml!DirectUI::CEventSourceBase<DirectUI::IUntypedEventSource,Windows::Foundation::IEventHandler<IInspectable *>,IInspectable,IInspectable>::UntypedRaise+0x43 [onecoreuap\windows\dxaml\xcp\dxaml\lib\JoltClasses.h @ 248]
000001a8`656c4108  00007ff9`19fb7c48 D2D1Debug3!DebugComObject<DebugFactory7Generated<ID2D1Factory7> >::`vftable'
000001a8`656c4110  00000000`00000001
000001a8`656c4118  00080000`00000000
000001a8`656c4120  f026b5be`dd1e28c9

Which is:

THROW_IF_FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, __uuidof(_p.d2dFactory), &options, reinterpret_cast<void**>(_p.d2dFactory.addressof())));

Metadata

Metadata

Assignees

No one assigned

    Labels

    In-PRThis issue has a related PRIssue-BugIt either shouldn't be doing this or needs an investigation.Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions