-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NULL HWND's attempted to be parented under SystemResources listener window cause unhanded exception #2089
Comments
@vatsan-madhavan Our native C++/WPF app with per-monitor v2, besides experiencing some of the crashes similar to the above, also seems to be experiencing some crashes with a slightly different call stack than some of the other reported issues I've seen. Is this a distinct issue that should be filed, or are multiple issues being addressed?
|
@teh173 please open a new issue for this one. if possible, share a minimal repro app and a crash dump so we can investigate further. |
Filed #2239 |
When an
HwndHost
receivesSourceChanged
event, it goes throughBuildOrReparentWindow
. When the hosted window is invisible, it is usually reparented under a temporary windows maintained by WPF in theSystemResources
class, until later on the window can be rebuilt and parented back to a valid parent.There is a latent bug in this logic where in
NULL
HWND's
are attempted to be parented toSystemResources
managed temporary windows. This bug goes back quite a while (.NET 4.5 likely). WPF seems to ignore the return value fromkernel32!SetParent
and not deal with this failure. This has not been a crashing failure until now.Starting .NET 4.8, there have been some changes to this codepath that have resulted in this bug becoming a crashing bug. In addition to calling
kernel32!SetParent
on aNULL HWND
, WPF attempts to perform several other operations on theHWND
, including querying its DPI characteristics (which returns invalid information). Once of the subsidiary steps returns an invalid value that in turn results in a crash with the following stack:This issue is related to, but not a duplicate of, #1198/#1953. That said, it affects the same sorts of scenarios described in #1198.
wpf/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/HwndHost.cs
Lines 979 to 997 in ac9d1b7
The text was updated successfully, but these errors were encountered: