Unexpected messages arriving while in RedrawWindow()

Troy Rollo wine at troy.rollo.name
Mon Jan 24 23:45:26 CST 2005


In RedrawWindow (dlls/user/painting.c:402) there is a call to 
MsgWaitForMultipleObjects:

    /* process pending events and messages before painting */
    if (flags & RDW_UPDATENOW)
        MsgWaitForMultipleObjects( 0, NULL, FALSE, 0, QS_ALLINPUT );

This call can result in messages arriving at an unrelated window, such as in 
the trace below. This will not happen under Windows - a single-threaded 
application will not receive a message in an unrelated window while 
RedrawWindow is on the stack (unless one of the windows that is supposed to 
be getting messages sends it or processes the message queue).

In the trace, the creation of the Combo Box (at stack frame 60) is part of the 
initialisation sequence for a window. During the creation of that box, 
RedrawWindow is called, and while in the MsgWaitForMultipleObjects code, an 
event arrives that causes SetWindowPos() to be called on the frame window 
containing the parent of the combo box, resulting in a WM_SIZE.

In this case, the WM_SIZE message triggers some operations in the parent of 
the combo box (at stack frames 0-4) that result in data used by an earlier 
stack frame (at frames 61-70) being changed unexpectedly.

A quick fix in the present case might be to take the "RDW_UPDATENOW" flag off 
the call to RedrawWindow() from CBResetPos(), since it seems unlikely that 
the flag is necessary, but it seems that doing so just masks the real 
problem.

The real fix would appear to be involve some queueing of events received other 
than those needed by RedrawWindow().
-------------- next part --------------
.... in application code....
#5  0x406f118f in WINPROC_wrapper () at ../../include/winbase.h:2056
#6  0x406f14fa in WINPROC_CallWndProc (proc=0x403550 <WndProc((short, HWND__*, unsigned int, unsigned int, long))>, hwnd=0x20046, msg=5, wParam=2, lParam=19858040) at ../../windows/winproc.c:419
#7  0x406f7fb7 in WINPROC_CallProc32WTo32A (func=0x403550 <WndProc((short, HWND__*, unsigned int, unsigned int, long))>, hwnd=0x20046, msg=5, wParam=2, lParam=19858040) at ../../windows/winproc.c:3053
#8  0x406f893f in CallWindowProcW (func=0x407a2dde <winproc_array+734>, hwnd=0x20046, msg=5, wParam=2, lParam=19858040) at ../../windows/winproc.c:3279
#9  0x40731071 in call_window_proc (hwnd=0x20046, msg=5, wparam=2, lparam=19858040, unicode=1, same_thread=1) at message.c:1473
#10 0x4073219f in SendMessageTimeoutW (hwnd=0x20046, msg=5, wparam=2, lparam=19858040, flags=0, timeout=4294967295, res_ptr=0x4067dbc4) at message.c:1936
#11 0x40732472 in SendMessageW (hwnd=0x20046, msg=5, wparam=2, lparam=19858040) at message.c:2017
#12 0x406cc9d6 in DEFWND_HandleWindowPosChanged (hwnd=0x20046, winpos=0x4067e054) at ../../windows/defwnd.c:75
#13 0x406cdc10 in DEFWND_DefWinProc (hwnd=0x20046, msg=71, wParam=0, lParam=1080549460) at ../../windows/defwnd.c:345
#14 0x406ce2dd in DefWindowProcA (hwnd=0x20046, msg=71, wParam=0, lParam=1080549460) at ../../windows/defwnd.c:851
#15 0x406d9319 in DefFrameProcA (hwnd=0x20046, hwndMDIClient=0x20044, message=71, wParam=0, lParam=1080549460) at ../../windows/mdi.c:1280
.... in application code ....
#19 0x406f118f in WINPROC_wrapper () at ../../include/winbase.h:2056
#20 0x406f14fa in WINPROC_CallWndProc (proc=0x403550 <WndProc((short, HWND__*, unsigned int, unsigned int, long))>, hwnd=0x20046, msg=71, wParam=0, lParam=1080549460) at ../../windows/winproc.c:419
#21 0x406f7fb7 in WINPROC_CallProc32WTo32A (func=0x403550 <WndProc((short, HWND__*, unsigned int, unsigned int, long))>, hwnd=0x20046, msg=71, wParam=0, lParam=1080549460) at ../../windows/winproc.c:3053
#22 0x406f893f in CallWindowProcW (func=0x407a2dde <winproc_array+734>, hwnd=0x20046, msg=71, wParam=0, lParam=1080549460) at ../../windows/winproc.c:3279
#23 0x40731071 in call_window_proc (hwnd=0x20046, msg=71, wparam=0, lparam=1080549460, unicode=1, same_thread=1) at message.c:1473
#24 0x4073219f in SendMessageTimeoutW (hwnd=0x20046, msg=71, wparam=0, lparam=1080549460, flags=0, timeout=4294967295, res_ptr=0x4067dfac) at message.c:1936
#25 0x40732472 in SendMessageW (hwnd=0x20046, msg=71, wparam=0, lparam=1080549460) at message.c:2017
#26 0x40ebae77 in X11DRV_SetWindowPos (winpos=0x4067e054) at winpos.c:885
#27 0x406f09cc in SetWindowPos (hwnd=0x20046, hwndInsertAfter=0x20026, x=0, y=4, cx=640, cy=350, flags=2147483664) at ../../windows/winpos.c:1200
#28 0x40ebc3e5 in X11DRV_ConfigureNotify (hwnd=0x20046, event=0x4067e1ac) at winpos.c:1480
#29 0x40ea51d5 in EVENT_ProcessEvent (event=0x4067e1ac) at event.c:348
#30 0x40ea4d68 in process_events (data=0x4037ff40) at event.c:128
#31 0x40ea4e4c in X11DRV_MsgWaitForMultipleObjectsEx (count=1, handles=0x4067e3ec, timeout=0, mask=255, flags=0) at event.c:162
#32 0x406db6e4 in MsgWaitForMultipleObjectsEx (count=0, pHandles=0x0, timeout=0, mask=255, flags=0) at ../../windows/message.c:596
#33 0x406db7a1 in MsgWaitForMultipleObjects (count=0, handles=0x0, wait_all=0, timeout=0, mask=255) at ../../windows/message.c:613
#34 0x40736d8c in RedrawWindow (hwnd=0x20040, rect=0x0, hrgn=0x0, flags=261) at painting.c:414
#35 0x406fe76a in CBResetPos (lphc=0x452a1e68, rectEdit=0x452a1e84, rectLB=0x452a1ea4, bRedraw=1) at combo.c:1599
#36 0x406fe7e6 in COMBO_Size (lphc=0x452a1e68) at combo.c:1616
#37 0x406fef84 in ComboWndProc_common (hwnd=0x20040, message=71, wParam=0, lParam=1080551548, unicode=0) at combo.c:1911
#38 0x40700425 in ComboWndProcA (hwnd=0x20040, message=71, wParam=0, lParam=1080551548) at combo.c:2281
#39 0x406f118f in WINPROC_wrapper () at ../../include/winbase.h:2056
#40 0x406f14fa in WINPROC_CallWndProc (proc=0x407003c0 <ComboWndProcA>, hwnd=0x20040, msg=71, wParam=0, lParam=1080551548) at ../../windows/winproc.c:419
#41 0x406f7fb7 in WINPROC_CallProc32WTo32A (func=0x407003c0 <ComboWndProcA>, hwnd=0x20040, msg=71, wParam=0, lParam=1080551548) at ../../windows/winproc.c:3053
#42 0x406f893f in CallWindowProcW (func=0x407a2b4a <winproc_array+74>, hwnd=0x20040, msg=71, wParam=0, lParam=1080551548) at ../../windows/winproc.c:3279
#43 0x40731071 in call_window_proc (hwnd=0x20040, msg=71, wparam=0, lparam=1080551548, unicode=1, same_thread=1) at message.c:1473
#44 0x4073219f in SendMessageTimeoutW (hwnd=0x20040, msg=71, wparam=0, lparam=1080551548, flags=0, timeout=4294967295, res_ptr=0x4067e7d4) at message.c:1936
#45 0x40732472 in SendMessageW (hwnd=0x20040, msg=71, wparam=0, lparam=1080551548) at message.c:2017
#46 0x40ebae77 in X11DRV_SetWindowPos (winpos=0x4067e87c) at winpos.c:885
#47 0x406f09cc in SetWindowPos (hwnd=0x20040, hwndInsertAfter=0x0, x=0, y=0, cx=223, cy=26, flags=22) at ../../windows/winpos.c:1200
#48 0x406fc21c in CBForceDummyResize (lphc=0x452a1e68) at combo.c:332
#49 0x406fc85a in COMBO_Create (hwnd=0x20040, lphc=0x452a1e68, hwndParent=0x2003e, style=1352728579, unicode=0) at combo.c:666
#50 0x406feee1 in ComboWndProc_common (hwnd=0x20040, message=1, wParam=0, lParam=1080552968, unicode=0) at combo.c:1875
#51 0x40700425 in ComboWndProcA (hwnd=0x20040, message=1, wParam=0, lParam=1080552968) at combo.c:2281
#52 0x406f118f in WINPROC_wrapper () at ../../include/winbase.h:2056
#53 0x406f14fa in WINPROC_CallWndProc (proc=0x407003c0 <ComboWndProcA>, hwnd=0x20040, msg=1, wParam=0, lParam=1080552968) at ../../windows/winproc.c:419
#54 0x406f87cf in CallWindowProcA (func=0x407003c0 <ComboWndProcA>, hwnd=0x20040, msg=1, wParam=0, lParam=1080552968) at ../../windows/winproc.c:3240
#55 0x40731108 in call_window_proc (hwnd=0x20040, msg=1, wparam=0, lparam=1080552968, unicode=0, same_thread=1) at message.c:1478
#56 0x407323e0 in SendMessageTimeoutA (hwnd=0x20040, msg=1, wparam=0, lparam=1080552968, flags=0, timeout=4294967295, res_ptr=0x4067eb18) at message.c:1984
#57 0x407324e2 in SendMessageA (hwnd=0x20040, msg=1, wparam=0, lparam=1080552968) at message.c:2028
#58 0x40eb887f in X11DRV_CreateWindow (hwnd=0x20040, cs=0x4067ee08, unicode=0) at window.c:1124
#59 0x406e9ad3 in WIN_CreateWindowEx (cs=0x4067ee08, classAtom=49153, type=WIN_PROC_32A) at ../../windows/win.c:1172
#60 0x406ea3b7 in CreateWindowExA (exStyle=0, className=0xb47d1a "COMBOBOX", windowName=0xb47d23 "", style=1352728579, x=3, y=3, width=223, height=314, parent=0x2003e, menu=0xce6, instance=0x400000, data=0x0) at ../../windows/win.c:1327
.... in application code ....
#71 0x406f118f in WINPROC_wrapper () at ../../include/winbase.h:2056
#72 0x406f14fa in WINPROC_CallWndProc (proc=0x403550 <WndProc((short, HWND__*, unsigned int, unsigned int, long))>, hwnd=0x10022, msg=256, wParam=13, lParam=0) at ../../windows/winproc.c:419
#73 0x406f87cf in CallWindowProcA (func=0x403550 <WndProc((short, HWND__*, unsigned int, unsigned int, long))>, hwnd=0x10022, msg=256, wParam=13, lParam=0) at ../../windows/winproc.c:3240
#74 0x40731108 in call_window_proc (hwnd=0x10022, msg=256, wparam=13, lparam=0, unicode=0, same_thread=1) at message.c:1478
#75 0x407323e0 in SendMessageTimeoutA (hwnd=0x10022, msg=256, wparam=13, lparam=0, flags=0, timeout=4294967295, res_ptr=0x4067f564) at message.c:1984
#76 0x407324e2 in SendMessageA (hwnd=0x10022, msg=256, wparam=13, lparam=0) at message.c:2028
.... in application code ....
#79 0x406f118f in WINPROC_wrapper () at ../../include/winbase.h:2056
#80 0x406f14fa in WINPROC_CallWndProc (proc=0x403550 <WndProc((short, HWND__*, unsigned int, unsigned int, long))>, hwnd=0x10022, msg=273, wParam=101, lParam=34) at ../../windows/winproc.c:419
#81 0x406f87cf in CallWindowProcA (func=0x407a2dd0 <winproc_array+720>, hwnd=0x10022, msg=273, wParam=101, lParam=34) at ../../windows/winproc.c:3240
#82 0x406dbe02 in DispatchMessageA (msg=0x4067f96c) at ../../windows/message.c:793
.... in application code ....
#85 0x00b1390b in _startup ()
#86 0x00000000 in ?? ()


More information about the wine-devel mailing list