Conformance test for bug #7286 (corrected version)

Misha Koshelev mk144210 at
Thu Feb 1 23:43:24 CST 2007

This is simply a conformance test for the patch that I submitted
earlier. This will tickle the bug #7286 that I described, and on current
wine git will report the error: "wineserver: object.c:274:
release_object: Assertion `obj->refcount' failed." for the same reason
as I previously described for that bug and for its patch. With my other
patch, it will work fine. The only thing of concern is that now since
there is a waiting APC that the conformance test thread is not picking
up, two further WaitForSingleObject calls with a timeout of 0 don't
actually time out (I think this might be because the select routine is
taking long enough where the actual object being waited on is ready now,
so its not really timing out for 0 milliseconds because APC checks are
happening, but I'm not 100% sure of this). Not sure if this is a
"regression" per se because without my other patch it is not even
possible to make it to that point in the conformance testing as
wineserver crashes, but it is of some concern.


	* Conformance test for a thread being the last object waiting on a
change directory handle.
-------------- next part --------------
From e86a03e0cb5a4eee143a86aaed17eb9973835d36 Mon Sep 17 00:00:00 2001
From: Misha Koshelev <mk144210 at>
Date: Thu, 1 Feb 2007 23:38:32 -0600
Subject: Added a conformance test that tickles bug 7286.
 dlls/kernel32/tests/change.c |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/dlls/kernel32/tests/change.c b/dlls/kernel32/tests/change.c
index bf7cdc1..fb9158e 100644
--- a/dlls/kernel32/tests/change.c
+++ b/dlls/kernel32/tests/change.c
@@ -84,8 +84,8 @@ static DWORD FinishNotificationThread(HA
 static void test_FindFirstChangeNotification(void)
-    HANDLE change, file, thread;
-    DWORD attributes, count;
+    HANDLE change, file, thread, events[2];
+    DWORD attributes, count, threadId, status, exitcode;
     BOOL ret;
     char workdir[MAX_PATH], dirname1[MAX_PATH], dirname2[MAX_PATH];
@@ -237,6 +237,28 @@ static void test_FindFirstChangeNotifica
     ok( ret, "CloseHandle error: %d\n", GetLastError());
     ok(FinishNotificationThread(thread), "Missed notification\n");
+    /*
+     * Test behavior if notification is being cancelled upon directory 
+     * object destruction when the main thread originated the first request
+     * for change notification. See bug #7286 
+     */
+    /* Start find first change notification function */
+    events[0] = FindFirstChangeNotificationA(workdir, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME);
+    ok(events[0] != INVALID_HANDLE_VALUE, "FindFirstChangeNotification error: %d\n", GetLastError());
+    /* Now create the notification thread */
+    events[1] = CreateThread(NULL, 0, NotificationThread, (LPVOID)events[0],
+                              0, &threadId);
+    ok(events[1] != NULL, "CreateThread error: %d\n", GetLastError());
+    /* This is the part that fails with bug #7286. Here refcount is 1 on 
+     * process awakening, which causes an APC to be sent to the process from
+     * within the end_wait function. Works fine on Windows XP. */
+    status = WaitForMultipleObjects(2, events, FALSE, 5000);
+    ok(status == WAIT_OBJECT_0 || status == WAIT_OBJECT_0+1, "WaitForMultipleObjects status %d error %d\n", status, GetLastError());
+    ok(GetExitCodeThread(thread, &exitcode), "Could not retrieve thread exit code\n");
     /* clean up */
     ret = DeleteFileA(filename2);

More information about the wine-patches mailing list