[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] thread: Wait for the thread if ObReferenceObjectByHandle fails


  • To: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>, "win-pv-devel@xxxxxxxxxxxxxxxxxxxx" <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Thu, 29 Oct 2026 09:35:56 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=I/SH19x/kCbkH0O+2Lso8BGFbBxn61yzjbhjGA0FQIo=; b=QeRXdvjoPXKKMdPyErBn+F6/XHBu4TzTPBKbcWix2QMh9kGsOeBe4w9zC2kokgUHEPLsQ5YYAsZaRdLIHiiegRhqe152HRuYNSwnISwxqa4EhI76UjT8w17taDsYUbkhJkAJbsTcoRtMav2aU0e8k3eyIxu/VM8KY4HboOpLBEQByxrvc0tsrGrlhkqBe1+KbNDNgdFceoQhQcaxFCSlPQHy3U6l4z1fRmvd3rKgdO0bG5akhyFmnU/lJSIK4fGnepmbJqgeIQxBYUIPurCKRRgu9kJlDzZPr3hgNyASy9PijsJvWN8sAeMCG6AXkqs9l4jKImrlpop0pgMmBtyY8w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mVzSaajpN+Z4g1gdswjQzLsYFZ3BeBULvygbi/2UOYi2pVlUXR+Bwkh1OQ5aiXW7uav8lmB1h4CXlZnFvqpV4M50evXjsmvCa7OF7BYnASyQ2VYgyC02M/LA/AjnBiObS9fXZ4RJhw+o1/2gNwCByOIOiQcNndoQOiefHD17yldevxCzjp1NuxUvfLROtE/Y4j3s6jP8De3JcIWE3vi9Ob7/bNvYgNw4WLM8i0dvkNvAZcSRStX2x9R1pgM4V1LehLnuHLiVaE8MNGgHbDAaVgKH1xSAE/gcqKsYfX1wJ3mXBd+tcpraieqFJEMPJCoa6zfzIua+YRlaAR0BvgGOww==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Delivery-date: Thu, 29 Oct 2026 09:37:45 +0000
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>
  • Msip_labels:
  • Thread-index: AQHdZU6HRDeywTDe6ki8PAPuk5dHz7cURwQp
  • Thread-topic: [PATCH] thread: Wait for the thread if ObReferenceObjectByHandle fails

This patch, and the patches fixing this across all drivers
Reviewed-by: Owen Smith <owen.smith@xxxxxxxxxx>

________________________________________
From: win-pv-devel <win-pv-devel-bounces@xxxxxxxxxxxxxxxxxxxx> on behalf of Tu 
Dinh <ngoc-tu.dinh@xxxxxxxxxx>
Sent: 26 October 2026 1:32 PM
To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
Cc: Tu Dinh
Subject: [PATCH] thread: Wait for the thread if ObReferenceObjectByHandle fails

If ObReferenceObjectByHandle fails, the thread would have already
started. We need to wait for it to exit before cleaning up.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
---
 src/xenbus/thread.c  | 2 ++
 src/xenfilt/thread.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/src/xenbus/thread.c b/src/xenbus/thread.c
index a8cfce2..9510307 100644
--- a/src/xenbus/thread.c
+++ b/src/xenbus/thread.c
@@ -30,6 +30,7 @@
  * SUCH DAMAGE.
  */

+#include <ntifs.h>
 #include <ntddk.h>

 #include "thread.h"
@@ -171,6 +172,7 @@ fail3:
     Error("fail3\n");

     __ThreadAlert(*Thread);
+    ZwWaitForSingleObject(Handle, FALSE, NULL);
     ZwClose(Handle);

 fail2:
diff --git a/src/xenfilt/thread.c b/src/xenfilt/thread.c
index e26469b..89f4f91 100644
--- a/src/xenfilt/thread.c
+++ b/src/xenfilt/thread.c
@@ -30,6 +30,7 @@
  * SUCH DAMAGE.
  */

+#include <ntifs.h>
 #include <ntddk.h>

 #include "thread.h"
@@ -171,6 +172,7 @@ fail3:
     Error("fail3\n");

     __ThreadAlert(*Thread);
+    ZwWaitForSingleObject(Handle, FALSE, NULL);
     ZwClose(Handle);

 fail2:
--
2.56.0.windows.4



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.