Repository navigation
Description
- .NET Core Version: All
- Windows version: All
- Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
Problem description:
We have been getting a crash when using the mouse on certain windows in our WPF application. This Stackoverflow issue appears with exactly the same error messages as our own so I believe it to be relevant. https://stackoverflow.com/questions/33287542/what-would-cause-wm-nchittest-lparam-to-overflow-a-32-bit-integer
This issue has also been reported to the Visual Studio community site and a simple test application has been provided. https://developercommunity.visualstudio.com/content/problem/167357/overflow-exception-in-windowchrome.html
The crashes occur on a Windows 10 Pro Version 1709 OS Build 16299.309, win7 sp1, Windows10 21H2 19044.1645
I run the application with .NET 6.0.5 and @contre run the application with .NET Framework 4.6.2
Actual behavior:
System.OverflowException
HResult=0x80131516
Message=Arithmetic operation resulted in an overflow.
Source=PresentationFramework
StackTrace:
at System.Windows.Shell.WindowChromeWorker._HandleNCHitTest(WM uMsg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Shell.WindowChromeWorker._WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.PublicHooksFilterMessage(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)
Expected behavior:
It can work well.
Minimal repro:
Any WPF application which use WindowChrome . But we must run the application on the special system.
- See System.OverflowException in PresentationFramework.dll in System.Windows.Shell.WindowChromeWorker microsoft/dotnet#689
- See OverflowException when converting 64-bit IntPtr to Int32 ControlzEx/ControlzEx#30
- See Arithmetic operation resulted in an overflow. MahApps/MahApps.Metro#3301
- See Exception:算术运算导致溢出。 HandyOrg/HandyControl#886
- See https://developercommunity.visualstudio.com/t/overflow-exception-in-windowchrome/167357
CC @batzen
Activity
Fix System.OverflowException in WindowChromeWorker._HandleNCHitTest
Fix System.OverflowException in WindowChromeWorker._HandleNCHitTest
Fix System.OverflowException in WindowChromeWorker._HandleNCHitTest (#…