Skip to content

Commit 9eca7c5

Browse files
committed
[WIN32K] ASSERT that all callout references have been cleaned up on thread exit
1 parent 6907831 commit 9eca7c5

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

win32ss/user/ntuser/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,9 @@ ExitThreadCallback(PETHREAD Thread)
813813
UserDereferenceObject(ref->obj);
814814

815815
psle = PopEntryList(&ptiCurrent->ReferencesList);
816+
#if DBG
817+
ptiCurrent->cRefObjectCo--;
818+
#endif
816819
}
817820
}
818821

@@ -872,6 +875,8 @@ ExitThreadCallback(PETHREAD Thread)
872875
}
873876
ptiCurrent->hEventQueueClient = NULL;
874877

878+
ASSERT(ptiCurrent->cRefObjectCo == 0);
879+
875880
/* The thread is dying */
876881
PsSetThreadWin32Thread(Thread /*ptiCurrent->pEThread*/, NULL, ptiCurrent);
877882

win32ss/user/ntuser/object.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
3434
UserReferenceEntry->obj = obj;
3535
UserReferenceObject(obj);
3636
PushEntryList(&W32Thread->ReferencesList, &UserReferenceEntry->Entry);
37+
#if DBG
38+
W32Thread->cRefObjectCo++;
39+
#endif
3740
}
3841

3942
static __inline VOID
@@ -53,6 +56,9 @@ UserDerefObjectCo(PVOID obj)
5356

5457
ASSERT(obj == UserReferenceEntry->obj);
5558
UserDereferenceObject(obj);
59+
#if DBG
60+
W32Thread->cRefObjectCo--;
61+
#endif
5662
}
5763

5864
void FreeProcMarkObject(_In_ PVOID Object);

win32ss/user/ntuser/win32.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ typedef struct _THREADINFO
158158
ULONG cExclusiveLocks;
159159
#if DBG
160160
USHORT acExclusiveLockCount[GDIObjTypeTotal + 1];
161+
UINT cRefObjectCo;
161162
#endif
162163
#endif // __cplusplus
163164
} THREADINFO;

0 commit comments

Comments
 (0)