microsoft / microsoft/microsoft-ui-xaml
Calling this->Close() on a Window sometimes throws an Access Violation exception
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
### Describe the bug
I have a Multi Window application:
My mainwindow activates WindowA. If the close button in WindowA is pressed, I call 'this->Close();' and WindowA closes, but sometimes it triggeres:
template auto consume_Microsoft_UI_Xaml_IWindow::Close() const
{
check_hresult(WINRT_IMPL_SHIM(winrt::Microsoft::UI::Xaml::IWindow)->Close());
}
of the App.exe!winrt::impl::consume_Microsoft_UI_Xaml_IWindow::Close() Zeile 4634 C++ (from Debuggers Call Chain)
But this WindowB wasn't activated so i Get this Exception:
Ausnahmefehler bei 0x00007FF8B3616DC0 (combase.dll) in App.exe: 0xC0000602: Ein sofortiger Ausnahmefehler ist aufgetreten. Die Ausnahmehandler werden nicht aufgerufen, und der Prozess wird sofort beendet
Ausnahme ausgelöst bei 0x00007FFFB7EE9853 (Microsoft.ui.xaml.dll) in App.exe: 0xC0000005: Zugriffsverletzung beim Lesen an Position 0x0000000000000018.
My debug output: (this is a mix of Visual Studio debug output and my own Exception log..)
Ausnahmefehler bei 0x00007FFFB79ADD55 (Microsoft.ui.xaml.dll) in App.exe: 0xC000027B: Anwendungsinterne Ausnahme (Parameter: 0x0000023AA0275B50, 0x0000000000000001)
Ausnahmefehler bei 0x00007FF8B3616DC0 (combase.dll) in App.exe: 0xC0000602: Ein sofortiger Ausnahmefehler ist aufgetreten. Die Ausnahmehandler werden nicht aufgerufen, und der Prozess wird sofort beendet
Ausnahme ausgelöst bei 0x00007FFFB7EE9853 (Microsoft.ui.xaml.dll) in App.exe: 0xC0000005: Zugriffsverletzung beim Lesen an Position 0x0000000000000018.
250506_08:59:03.1999722 ERR App: Exception: Code: C0000005 @ 0x7FFFB7EE9853 | Access Violation: Read @ 0x0000000000000018
Ausnahme ausgelöst bei 0x00007FF8B247831A (KernelBase.dll) in App.exe: 0x80010105: Ausnahmefehler des Servers.
Ausnahme ausgelöst bei 0x00007FF8B247831A (KernelBase.dll) in App.exe: WinRT originate error - 0x80010105 : 'Ausnahmefehler des Servers.'.
Ausnahme ausgelöst bei 0x00007FF8B247831A in App.exe: Microsoft C++-Ausnahme: winrt::hresult_error bei Speicherort 0x00000093CC89F7F0.
Ausnahme ausgelöst bei 0x00007FF8B247831A in App.exe: Microsoft C++-Ausnahme: winrt::hresult_error bei Speicherort 0x00000093CC89D370.
250506_08:59:05.0136242 ERR App: Exception: Code: 80010105 @ 0x7FF8B247831A | Unknown Exception
250506_08:59:05.0137460 ERR App: WinRT Exception: unknown @ D:\Projects\source\myAPP\myAPP\myAPP\Generated Files\winrt\base.h : 9183 | HRESULT: 0x80010105 | Description: Ausnahmefehler des Servers.
250506_08:59:05.0141353 ERR App: Exception: Code: 40080201 @ 0x7FF8B247831A | WinRT internal parse error
250506_08:59:05.0143379 ERR App: WinRT Exception: unknown @ D:\Projects\source\myAPP\myAPP\myAPP\Generated Files\winrt\base.h : 9183 | HRESULT: 0x80010105 | Description: Ausnahmefehler des Servers.
250506_08:59:05.0147444 ERR App: Exception: Code: E06D7363 @ 0x7FF8B247831A | C++ Exception
250506_08:59:05.0151490 ERR App: Exception: Code: E06D7363 @ 0x7FF8B247831A | C++ Exception
As result of this the WindowA stays open (black).
If I click on it again I get:
Ausnahme ausgelöst bei 0x00007FFFB7738967 (Microsoft.ui.xaml.dll) in UniHarp.exe: 0xC0000005: Zugriffsverletzung beim Lesen an Position 0x0000000000000058.
in
template auto consume_Microsoft_UI_Xaml_IApplicationStatics::Start(winrt::Microsoft::UI::Xaml::ApplicationInitializationCallback const& callback) const
{
check_hresult(WINRT_IMPL_SHIM(winrt::Microsoft::UI::Xaml::IApplicationStatics)->Start(*(void**)(&callback)));
}
### Steps to reproduce the bug
.
### Expected behavior
_No response_
### Screenshots
_No response_
### NuGet package version
None
### Packaging type
_No response_
### Windows version
_No response_
### IDE
_No response_
### Additional context
_No response_
Contributor guide
Research direction
Start by reducing the reported multi-window scenario to a minimal reproduction for calling Close() on WindowA, then inspect the Close() call chain shown in the report, including Generated Files/winrt/base.h. Capture the Windows, IDE, packaging, and WinUI package details that are currently missing. Done means a reproducible failure or a confirmed explanation and fix for the access violation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- desktop, frontend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100