This test is failing from time to time. Making sure the parent thread is complete before continuing triggers the underlying race condition -see next patch- and makes the test to always fail.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
Notes: The failure was hard to reproduce. The most reliable way without the sleep added here is to start multiple runs on the testbot, changing locale for each run. The locale change seems to have an impact on the timing and triggers the race condition.
dlls/user32/tests/msg.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 193a20fd958..2f3f70076e9 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -8551,6 +8551,7 @@ struct wnd_event HANDLE grand_child; HANDLE start_event; HANDLE stop_event; + HANDLE child_stopped_event; };
static DWORD WINAPI thread_proc(void *param) @@ -8580,6 +8581,7 @@ static DWORD CALLBACK create_grand_child_thread( void *param ) struct wnd_event *wnd_event = param; HWND hchild; MSG msg; + DWORD ret;
hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE, 0, 0, 10, 10, wnd_event->hwnd, 0, 0, NULL); @@ -8588,6 +8590,9 @@ static DWORD CALLBACK create_grand_child_thread( void *param ) flush_sequence(); SetEvent( wnd_event->start_event );
+ ret = WaitForSingleObject( wnd_event->child_stopped_event, 500 ); + ok( !ret, "WaitForSingleObject failed %x\n", ret ); + for (;;) { MsgWaitForMultipleObjects(0, NULL, FALSE, 1000, QS_ALLINPUT); @@ -8611,6 +8616,7 @@ static DWORD CALLBACK create_child_thread( void *param ) flush_events(); flush_sequence(); child_event.start_event = wnd_event->start_event; + child_event.child_stopped_event = wnd_event->child_stopped_event; wnd_event->grand_child = CreateThread(NULL, 0, create_grand_child_thread, &child_event, 0, &tid); for (;;) { @@ -8756,6 +8762,7 @@ static void test_interthread_messages(void) log_all_parent_messages++; wnd_event.start_event = CreateEventA( NULL, TRUE, FALSE, NULL ); wnd_event.stop_event = CreateEventA( NULL, TRUE, FALSE, NULL ); + wnd_event.child_stopped_event = CreateEventA( NULL, TRUE, FALSE, NULL ); hThread = CreateThread( NULL, 0, create_child_thread, &wnd_event, 0, &tid ); for (;;) { @@ -8770,14 +8777,17 @@ static void test_interthread_messages(void) ok( !ret, "WaitForSingleObject failed %x\n", ret ); CloseHandle( hThread );
+ SetEvent( wnd_event.child_stopped_event ); ret = WaitForSingleObject( wnd_event.grand_child, 5000 ); + todo_wine ok( !ret, "WaitForSingleObject failed %x\n", ret ); CloseHandle( wnd_event.grand_child );
CloseHandle( wnd_event.start_event ); CloseHandle( wnd_event.stop_event ); + CloseHandle( wnd_event.child_stopped_event ); flush_events(); - ok_sequence(WmExitThreadSeq, "destroy child on thread exit", FALSE); + ok_sequence(WmExitThreadSeq, "destroy child on thread exit", TRUE); log_all_parent_messages--; DestroyWindow( wnd_event.hwnd );
On thread destroy, a WM_WINE_DESTROYWINDOW is sent for the children windows owned by other threads. However there's then a race condition between these threads peeking for messages and the current thread detaching its child windows from their owning threads -which clears their message queues.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/tests/msg.c | 3 +-- server/window.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 2f3f70076e9..c7d61e4df07 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -8779,7 +8779,6 @@ static void test_interthread_messages(void)
SetEvent( wnd_event.child_stopped_event ); ret = WaitForSingleObject( wnd_event.grand_child, 5000 ); - todo_wine ok( !ret, "WaitForSingleObject failed %x\n", ret ); CloseHandle( wnd_event.grand_child );
@@ -8787,7 +8786,7 @@ static void test_interthread_messages(void) CloseHandle( wnd_event.stop_event ); CloseHandle( wnd_event.child_stopped_event ); flush_events(); - ok_sequence(WmExitThreadSeq, "destroy child on thread exit", TRUE); + ok_sequence(WmExitThreadSeq, "destroy child on thread exit", FALSE); log_all_parent_messages--; DestroyWindow( wnd_event.hwnd );
diff --git a/server/window.c b/server/window.c index c9b131cba5d..3985ea4eb20 100644 --- a/server/window.c +++ b/server/window.c @@ -1914,7 +1914,7 @@ void destroy_window( struct window *win ) post_message( win->parent->handle, WM_PARENTNOTIFY, WM_DESTROY, win->handle ); }
- detach_window_thread( win ); + if (win->thread == current) detach_window_thread( win ); if (win->win_region) free_region( win->win_region ); if (win->update_region) free_region( win->update_region ); if (win->class) release_class( win->class );
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=59551
Your paranoid android.
=== w8 (32 bit report) ===
user32: msg.c:8594: Test failed: WaitForSingleObject failed ffffffff msg.c:14720: Test failed: unexpected message 31f msg.c:14721: Test failed: bad wparam 1 msg.c:14727: Test failed: unicode WM_CHAR: 0: the msg sequence is not complete: expected 0102 - actual 0000
=== w1064v1809 (32 bit report) ===
user32: msg.c:9413: Test failed: Shift+MouseButton press/release: 12: in msg 0x0202 expecting wParam 0x4 got 0x0 msg.c:9413: Test failed: Shift+MouseButton press/release: 13: in msg 0x0202 expecting wParam 0x4 got 0x0
=== w1064v1809 (64 bit report) ===
user32: msg.c:10356: Test failed: did not get expected count for minimum timeout (53 != ~100).
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=59550
Your paranoid android.
=== w8 (32 bit report) ===
user32: msg.c:8594: Test failed: WaitForSingleObject failed ffffffff
=== w1064v1809 (32 bit report) ===
user32: msg.c:9414: Test failed: Shift+MouseButton press/release: 12: in msg 0x0202 expecting wParam 0x4 got 0x0 msg.c:9414: Test failed: Shift+MouseButton press/release: 13: in msg 0x0202 expecting wParam 0x4 got 0x0 msg.c:17777: Test failed: Restore minimized window: 41: the msg sequence is not complete: expected 0000 - actual 0007
=== w1064v1809_2scr (32 bit report) ===
user32: msg.c:10287: Test failed: did not get expected count for minimum timeout (54 != ~100).
=== w1064v1809_ja (32 bit report) ===
user32: msg.c:8773: Test failed: MsgWaitForMultipleObjects failed 102
=== w1064v1809 (64 bit report) ===
user32: msg.c:8594: Test failed: WaitForSingleObject failed ffffffff msg.c:10357: Test failed: did not get expected count for minimum timeout (52 != ~100).