Author: tfaber
Date: Tue Jun 20 17:15:43 2017
New Revision: 75152
URL:
http://svn.reactos.org/svn/reactos?rev=75152&view=rev
Log:
[RTL]
- Correctly use the page heap's lock in RtlLockHeap/RtlUnlockHeap when appropriate.
Fixes assertion failure when Global/Local memory allocations are performed concurrently
with DPH enabled.
Modified:
trunk/reactos/sdk/lib/rtl/heap.c
trunk/reactos/sdk/lib/rtl/heap.h
trunk/reactos/sdk/lib/rtl/heappage.c
Modified: trunk/reactos/sdk/lib/rtl/heap.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/rtl/heap.c?rev=751…
==============================================================================
--- trunk/reactos/sdk/lib/rtl/heap.c [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/rtl/heap.c [iso-8859-1] Tue Jun 20 17:15:43 2017
@@ -2982,7 +2982,11 @@
{
PHEAP Heap = (PHEAP)HeapPtr;
- // FIXME Check for special heap
+ /* Check for page heap */
+ if (Heap->ForceFlags & HEAP_FLAG_PAGE_ALLOCS)
+ {
+ return RtlpPageHeapLock(Heap);
+ }
/* Check if it's really a heap */
if (Heap->Signature != HEAP_SIGNATURE) return FALSE;
@@ -3015,7 +3019,11 @@
{
PHEAP Heap = (PHEAP)HeapPtr;
- // FIXME Check for special heap
+ /* Check for page heap */
+ if (Heap->ForceFlags & HEAP_FLAG_PAGE_ALLOCS)
+ {
+ return RtlpPageHeapUnlock(Heap);
+ }
/* Check if it's really a heap */
if (Heap->Signature != HEAP_SIGNATURE) return FALSE;
Modified: trunk/reactos/sdk/lib/rtl/heap.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/rtl/heap.h?rev=751…
==============================================================================
--- trunk/reactos/sdk/lib/rtl/heap.h [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/rtl/heap.h [iso-8859-1] Tue Jun 20 17:15:43 2017
@@ -436,6 +436,12 @@
SIZE_T Size);
BOOLEAN NTAPI
+RtlpPageHeapLock(HANDLE HeapPtr);
+
+BOOLEAN NTAPI
+RtlpPageHeapUnlock(HANDLE HeapPtr);
+
+BOOLEAN NTAPI
RtlpPageHeapGetUserInfo(PVOID HeapHandle,
ULONG Flags,
PVOID BaseAddress,
Modified: trunk/reactos/sdk/lib/rtl/heappage.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/rtl/heappage.c?rev…
==============================================================================
--- trunk/reactos/sdk/lib/rtl/heappage.c [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/rtl/heappage.c [iso-8859-1] Tue Jun 20 17:15:43 2017
@@ -2349,4 +2349,32 @@
return RtlValidateHeap(DphRoot->NormalHeap, Flags, BlockInfo);
}
+BOOLEAN
+NTAPI
+RtlpPageHeapLock(HANDLE HeapPtr)
+{
+ PDPH_HEAP_ROOT DphRoot;
+
+ /* Get pointer to the heap root */
+ DphRoot = RtlpDphPointerFromHandle(HeapPtr);
+ if (!DphRoot) return FALSE;
+
+ RtlpDphEnterCriticalSection(DphRoot, DphRoot->HeapFlags);
+ return TRUE;
+}
+
+BOOLEAN
+NTAPI
+RtlpPageHeapUnlock(HANDLE HeapPtr)
+{
+ PDPH_HEAP_ROOT DphRoot;
+
+ /* Get pointer to the heap root */
+ DphRoot = RtlpDphPointerFromHandle(HeapPtr);
+ if (!DphRoot) return FALSE;
+
+ RtlpDphLeaveCriticalSection(DphRoot);
+ return TRUE;
+}
+
/* EOF */