Description
openedon Feb 16, 2021
- .NET Core Version: .NET 5.0.3
- Windows version: Win10x64 20H2
- Does the bug reproduce also in WPF for .NET Framework 4.8?: Not tested
- Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? no
Problem description:
My WPF application sometimes crashes (see stacktrace below). As you can see from the stacktrace the issue is not caused by my code.
I did some testing and found the application causing my WPF application to crash. In my case NZXT CAM (https://www.nzxt.com/camapp) is responsible for the crashes. The issue can only be reproduced on machines with CAM running.
CAM (a real piss of shit software...but required for controlling the CPU cooler) thinks it has to play task manager and display applications using lots of CPU time. I guess CAM calls GetWindowText
to get the name of the application to display in it's "task-list".
I know you can't to anything about CAM causing problems...but I think a WPF app should not crash just because another process is trying to read it's window title...? Please consider that not a lot of devs are running this software any may never see this error on their machine...but there are some "real" users there running CAM on their PC...and they don't have a single chance to trace this error back to CAM.
Actual behavior:
System.ComponentModel.Win32Exception
HResult=0x80004005
Message=A device attached to the system is not functioning.
Source=WindowsBase
StackTrace:
at MS.Win32.UnsafeNativeMethods.GetWindowText(HandleRef hWnd, StringBuilder lpString, Int32 nMaxCount)
at System.Windows.Automation.Peers.WindowAutomationPeer.GetNameCore()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.ContextLayoutManager.fireAutomationEvents()
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run()
at MyApp.App.Main()
This exception was originally thrown at this call stack:
[External Code]
Expected behavior:
Calls to GetWindowText from other processes should not be able to crash a WPF application.
Minimal repro:
I don't know how I should create a minimal repro for this...but if you tell me what additional data you need I will try to provide it to you.