Application crashes when moving to a High DPI monitor (Issue #22513)

147 views
Skip to first unread message

Reza Karimi

unread,
Jun 10, 2022, 1:32:44 PM6/10/22
to wx-...@googlegroups.com, Subscribed

My application crashes when I try to move it to a High DPI monitor. I inspected the crash dump but I could not find anything useful.

My assumption so far:
My application has a custom splitter widgets which I call
wxWindow::ChildrenRepositioningGuard ds( ctrl_ );
for it to avoid flickering. Everything works fine on normal DPI. The crash happens in "EndRepositioningChildren" function. The following is just a sample call stack when the crash happens:

 	ucrtbase.dll!abort�()	Unknown

 	ucrtbase.dll!common_assert_to_stderr<wchar_t>()	Unknown

 	ucrtbase.dll!_wassert�()	Unknown

 	fuit.exe!MyApp::OnAssertFailure(const wchar_t * file, int line, const wchar_t * func, const wchar_t * cond, const wchar_t * msg) Line 707	C++

 	fuit.exe!wxDefaultAssertHandler(const wxString & file, int line, const wxString & func, const wxString & cond, const wxString & msg) Line 1183	C++

 	fuit.exe!wxOnAssert(const char * file, int line, const char * func, const char * cond, const wchar_t * msg) Line 1269	C++

>	fuit.exe!wxWindow::EndRepositioningChildren() Line 5698	C++

 	[Inline Frame] fuit.exe!wxWindowBase::ChildrenRepositioningGuard::{dtor}() Line 610	C++

 	fuit.exe!wxWindow::HandleSize(int __formal, int __formal, unsigned int wParam) Line 5766	C++

 	fuit.exe!wxWindow::MSWHandleMessage(__int64 * result, unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 3009	C++

 	fuit.exe!wxWindow::MSWWindowProc(unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 3888	C++

 	fuit.exe!wxScrolled<wxPanel>::MSWWindowProc(unsigned int nMsg, unsigned __int64 wParam, __int64 lParam) Line 468	C++

 	fuit.exe!wxWndProc(HWND__ * hWnd, unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 2929	C++

 	user32.dll!UserCallWinProcCheckWow()	Unknown

 	user32.dll!SendMessageWorker(struct tagWND *,unsigned int,unsigned __int64,__int64,int)	Unknown

 	user32.dll!RealDefWindowProcWorker()	Unknown

 	user32.dll!RealDefWindowProcW()	Unknown

 	uxtheme.dll!_ThemeDefWindowProc()	Unknown

 	uxtheme.dll!ThemeDefWindowProcW�()	Unknown

 	user32.dll!DefWindowProcW()	Unknown

 	fuit.exe!wxWindow::MSWDefWindowProc(unsigned int nMsg, unsigned __int64 wParam, __int64 lParam) Line 2472	C++

 	fuit.exe!wxWindow::MSWWindowProc(unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 3894	C++

 	fuit.exe!wxScrolled<wxPanel>::MSWWindowProc(unsigned int nMsg, unsigned __int64 wParam, __int64 lParam) Line 468	C++

 	fuit.exe!wxWndProc(HWND__ * hWnd, unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 2929	C++

 	user32.dll!UserCallWinProcCheckWow()	Unknown

 	user32.dll!DispatchClientMessage()	Unknown

 	user32.dll!__fnINLPWINDOWPOS�()	Unknown

 	ntdll.dll!KiUserCallbackDispatcherContinue�()	Unknown

 	win32u.dll!NtUserMessageCall�()	Unknown

 	user32.dll!RealDefWindowProcWorker()	Unknown

 	user32.dll!RealDefWindowProcW()	Unknown

 	uxtheme.dll!DoMsgDefault(struct _THEME_MSG const *)	Unknown

 	uxtheme.dll!OnDwpSysCommand()	Unknown

 	uxtheme.dll!_ThemeDefWindowProc()	Unknown

 	uxtheme.dll!ThemeDefWindowProcW�()	Unknown

 	user32.dll!DefWindowProcW()	Unknown

 	fuit.exe!wxWindow::MSWDefWindowProc(unsigned int nMsg, unsigned __int64 wParam, __int64 lParam) Line 2472	C++

 	fuit.exe!wxWindow::MSWWindowProc(unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 3894	C++

 	fuit.exe!wxNonOwnedWindow::MSWWindowProc(unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 262	C++

 	fuit.exe!wxTopLevelWindowMSW::MSWWindowProc(unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 327	C++

 	fuit.exe!wxFrame::MSWWindowProc(unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 912	C++

 	fuit.exe!wxWndProc(HWND__ * hWnd, unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 2929	C++

 	user32.dll!UserCallWinProcCheckWow()	Unknown

 	user32.dll!DispatchClientMessage()	Unknown

 	user32.dll!__fnDWORD�()	Unknown

 	ntdll.dll!KiUserCallbackDispatcherContinue�()	Unknown

 	win32u.dll!NtUserMessageCall�()	Unknown

 	user32.dll!RealDefWindowProcWorker()	Unknown

 	user32.dll!RealDefWindowProcW()	Unknown

 	uxtheme.dll!DoMsgDefault(struct _THEME_MSG const *)	Unknown

 	uxtheme.dll!OnDwpNcLButtonDown()	Unknown

 	uxtheme.dll!_ThemeDefWindowProc()	Unknown

 	uxtheme.dll!ThemeDefWindowProcW�()	Unknown

 	user32.dll!DefWindowProcW()	Unknown

 	fuit.exe!wxWindow::MSWDefWindowProc(unsigned int nMsg, unsigned __int64 wParam, __int64 lParam) Line 2472	C++

 	fuit.exe!wxWindow::MSWWindowProc(unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 3894	C++

 	fuit.exe!wxNonOwnedWindow::MSWWindowProc(unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 262	C++

 	fuit.exe!wxTopLevelWindowMSW::MSWWindowProc(unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 327	C++

 	fuit.exe!wxFrame::MSWWindowProc(unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 912	C++

 	fuit.exe!wxWndProc(HWND__ * hWnd, unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 2929	C++

 	user32.dll!UserCallWinProcCheckWow()	Unknown

 	user32.dll!DispatchMessageWorker()	Unknown

 	fuit.exe!wxGUIEventLoop::Dispatch() Line 227	C++

 	[Inline Frame] fuit.exe!wxEventLoopManual::ProcessEvents() Line 234	C++

 	fuit.exe!wxEventLoopManual::DoRun() Line 288	C++

 	fuit.exe!wxEventLoopBase::Run() Line 87	C++

 	fuit.exe!wxAppConsoleBase::MainLoop() Line 377	C++

 	fuit.exe!wxEntryReal(int & argc, wchar_t * * argv) Line 504	C++

 	fuit.exe!wxEntry(int & argc, wchar_t * * argv) Line 175	C++

 	fuit.exe!main(int argc, char * * argv) Line 1162	C++

 	[Inline Frame] fuit.exe!invoke_main() Line 78	C++

 	fuit.exe!__scrt_common_main_seh() Line 288	C++

 	kernel32.dll!BaseThreadInitThunk�()	Unknown

 	ntdll.dll!RtlUserThreadStart�()	Unknown




To Reproduce
Still working on it.

Platform and version information

  • wxWidgets version I use: 3.1.5
  • wxWidgets port I use: wxMSW
  • OS and its version: Windows 10


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22513@github.com>

VZ

unread,
Jun 10, 2022, 1:54:40 PM6/10/22
to wx-...@googlegroups.com, Subscribed

The cause of the problem seems clear enough, you're getting an assertion failure due to somehow not calling BeginRepositioningChildren() before or calling EndRepositioningChildren() twice. This is not supposed to happen when using ChildrenRepositioningGuard, of course, so it's not clear why it does, but you should be able to debug it easily by just putting breakpoints on both functions and seeing where they're called from.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22513/1152601960@github.com>

Reza Karimi

unread,
Jun 13, 2022, 4:19:18 AM6/13/22
to wx-...@googlegroups.com, Subscribed

I checked the source code. I don't use BeginRepositioningChildren() anywhere. I only use ChildrenRepositioningGuard when I need it and it should be safe according to the doc. Also you can see on the crash call stack that it comes from wxWindow::HandleSize function and then the destructor of ChildrenRepositioningGuard. So I think this is a bug in wx.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22513/1153618272@github.com>

Reza Karimi

unread,
Jun 13, 2022, 4:25:26 AM6/13/22
to wx-...@googlegroups.com, Subscribed

image

This is the value of repositionGuard in HandleSize function. Maybe helps


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22513/1153625151@github.com>

VZ

unread,
Jun 13, 2022, 7:14:21 AM6/13/22
to wx-...@googlegroups.com, Subscribed

Yes, the window passed to ChildrenRepositioningGuard ctor must remain alive at least for the duration this object lifetime. How does it happen that it gets destroyed in your case? It's not really expected for the windows to disappear during a re-layout...


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22513/1153787613@github.com>

Reza Karimi

unread,
Jun 13, 2022, 7:17:18 AM6/13/22
to wx-...@googlegroups.com, Subscribed

I don't destroy it anywhere as far as I know but I will double check it. Does wx do it somewhere because of DPI change?


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22513/1153790341@github.com>

VZ

unread,
Jun 13, 2022, 7:21:01 AM6/13/22
to wx-...@googlegroups.com, Subscribed

No, the library will never going to destroy user-created windows on its own.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22513/1153793656@github.com>

Reply all
Reply to author
Forward
0 new messages