microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.33k stars 676 forks source link

Troubles debugging a XAML issue #7165

Closed DavidXanatos closed 2 years ago

DavidXanatos commented 2 years ago

Hello

I'm running into a crash

Exception thrown at 0x00007FF8D2BC07AC (KernelBase.dll) in CredentialUIBroker.exe: WinRT originate error - 0x80004005 : 'Cannot locate resource from 'ms-appx:///Microsoft.UI.Xaml/Themes/21h1_themeresources.xaml'.'.
'CredentialUIBroker.exe' (Win32): Loaded 'C:\Windows\System32\bcrypt.dll'. Symbols loaded.
Exception thrown at 0x00007FF8D2BC07AC in CredentialUIBroker.exe: Microsoft C++ exception: winrt::hresult_error at memory location 0x000000C94097F0F0.
    KernelBase.dll!RaiseException()    Unknown
    Microsoft.UI.Xaml.dll!_CxxThrowException(void * pExceptionObject, const _s__ThrowInfo * pThrowInfo) Line 75 C++
    Microsoft.UI.Xaml.dll!winrt::throw_hresult(const winrt::hresult result) Line 4892   C++
>   [Inline Frame] Microsoft.UI.Xaml.dll!winrt::check_hresult(const winrt::hresult) Line 4962   C++
    Microsoft.UI.Xaml.dll!winrt::impl::consume_Windows_UI_Xaml_IResourceDictionary<XamlControlsResources>::Source(const winrt::Windows::Foundation::Uri & value) Line 2209  C++
    Microsoft.UI.Xaml.dll!XamlControlsResources::UpdateSource() Line 136    C++
    [Inline Frame] Microsoft.UI.Xaml.dll!XamlControlsResources::{ctor}() Line 31    C++
    Microsoft.UI.Xaml.dll!winrt::impl::heap_implements<XamlControlsResources>::heap_implements<XamlControlsResources>() C++
    [Inline Frame] Microsoft.UI.Xaml.dll!winrt::make() Line 7703    C++
    [Inline Frame] Microsoft.UI.Xaml.dll!winrt::Microsoft::UI::Xaml::Controls::factory_implementation::XamlControlsResourcesT<winrt::Microsoft::UI::Xaml::Controls::XamlControlsResourcesFactory,XamlControlsResources>::ActivateInstance() Line 42 C++
    Microsoft.UI.Xaml.dll!winrt::impl::produce<winrt::Microsoft::UI::Xaml::Controls::XamlControlsResourcesFactory,winrt::Windows::Foundation::IActivationFactory>::ActivateInstance(void * * instance) Line 6300    C++
    Windows.UI.XamlHost.dll!winrt::Windows::Foundation::IActivationFactory::ActivateInstance<struct winrt::Microsoft::UI::Xaml::Controls::XamlControlsResources>(void)  Unknown
    Windows.UI.XamlHost.dll!<lambda_1f68f4413181401bb9e1178e14cf0745>::<lambda_invoker_cdecl>(struct winrt::Windows::Foundation::IActivationFactory const &)    Unknown
    Windows.UI.XamlHost.dll!winrt::impl::factory_cache_entry<struct winrt::Microsoft::UI::Xaml::Controls::XamlControlsResources,struct winrt::Windows::Foundation::IActivationFactory>::call<struct winrt::Microsoft::UI::Xaml::Controls::XamlControlsResources (*)(struct winrt::Windows::Foundation::IActivationFactory const &)>(struct winrt::Microsoft::UI::Xaml::Controls::XamlControlsResources (*&&)(struct winrt::Windows::Foundation::IActivationFactory const &))    Unknown
    Windows.UI.XamlHost.dll!winrt::Microsoft::UI::Xaml::Controls::XamlControlsResources::XamlControlsResources(void)    Unknown
    Windows.UI.XamlHost.dll!XAMLHostWindowImpl::_SetupApplicationResources(void)    Unknown
    Windows.UI.XamlHost.dll!XAMLHostWindowImpl::_InitializeXamlContent(void)    Unknown
    Windows.UI.XamlHost.dll!XAMLHostWindowImpl::_CreateHostWindow(void) Unknown
    Windows.UI.XamlHost.dll!XAMLHostWindowImpl::_Show(void) Unknown
    Windows.UI.XamlHost.dll!<lambda>(void)()    Unknown
    Windows.UI.XamlHost.dll!ASTAThreadHost::ASTAThreadHostStartThreadProc(unsigned long)    Unknown
    Windows.UI.XamlHost.dll!ASTAThreadHost::s_ASTAThreadHostStartThreadProc()   Unknown
    SHCore.dll!_WrapperThreadProc() Unknown
    kernel32.dll!BaseThreadInitThunk()  Unknown
    ntdll.dll!RtlUserThreadStart() Unknown

When I try to debug this i get the following error message:

You need to find base.h to view the source for the current call stack frame

Source Link Error:
git-credential-manager-core.exe: Could not obtain credentials. Process failed with exit code -532462766.
ERROR: The request failed with code 404 : "Not Found". Treating 404 as authentication failure. Some services return 404 instead of 401 for authentication failures.

Source Link URL: https://raw.githubusercontent.com/microsoft/microsoft-ui-xaml/7ac3c8dfe2f6269d963d4cf44a4f666ea0a58d12/BuildOutput/Intermediates/x64/Microsoft.UI.Xaml/obj/Generated Files/winrt/base.h

Apparently this BuildOutput is no longer online? Can I find the right source version some ware else?

And before you ask how I produce this crash, its CredentialUIBroker.exe running under sandboxie's supervision on windows 11 on 10 it works fine. So I have to understand what's causing the crash and find a fix without being able to change anything but sandboxie itself, fun!

It is quite strange that being sandboxed makes the process fail to locate resource, the issue is present even without most sbie isolation mechanisms being engaged, only COM virtualization is enough to break it, and I cant test without that as than the calling process talks to the real system and starts a un sandboxed CredentialUIBroker.exe

Any help/advice would be greatly appreciated.

isaak654 commented 2 years ago

@StephenLPeters @ojhad @asklar Please consider assigning meaningful labels and/or a specific title to this issue.

kmahone commented 2 years ago

@DavidXanatos base.h is a generated file from C++/WinRT and that is why it is not showing up in the GitHub repo and why the debugger cannot locate it. However, I don't think it would help debugging this issue very much anyway since that file mostly contains simple helper functions that are used by C++/WinRT. In this case 'check_hresult' is converting an error HRESULT to an exception. The real issue is what you see in the exception: 'Cannot locate resource from 'ms-appx:///Microsoft.UI.Xaml/Themes/21h1_themeresources.xaml'.'

How is this program consuming Microsoft.UI.Xaml? Is it coming from the framework work package or is it included in the app itself? You can check this by looking at the path to Microsoft.UI.Xaml.dll and seeing if it is inside the app package or if it is in the dedicated "Microsoft.UI.Xaml" framework package path (e.g. something like C:\Program Files\WindowsApps\Microsoft.UI.Xaml.2.7...).

If it is coming from the framework package path, make sure that the app's appxmanifest as a packagedependency on Microsoft.UI.Xaml.

DavidXanatos commented 2 years ago

hmmm... well as this file is the CredentialUIBroker.exe its located in c:\Windows\System32\ and those has no app package of its own, it is loading this one: 'C:\Windows\SystemApps\Microsoft.UI.Xaml.CBS_8wekyb3d8bbwe\Microsoft.UI.Xaml.dll'

kmahone commented 2 years ago

In that case it should be loading the resources from the resources.pri that is next to M.U.X.dll in that directory. It seems like that resources.pri file is not getting loaded for some reason.

DavidXanatos commented 2 years ago

Thanks for the help, I solved the issue, for the time being its working fine :)