From bfebd2b3c9a91a436d3c5eeef2cfab8af8d335f8 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 5 Aug 2023 13:55:11 -0400 Subject: [PATCH] libroot: Acquire the process heap lock. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Upon further investigation, the global heap lock should actually not need to be reset, but the process heap lock will. Change-Id: Id1fd91cc0e7acecd5b4fd76cb82d4ed2ae3900ad Reviewed-on: https://review.haiku-os.org/c/haiku/+/6777 Reviewed-by: Jérôme Duval Tested-by: Commit checker robot Reviewed-by: waddlesplash --- src/system/libroot/posix/malloc_hoard2/arch-specific.cpp | 2 -- src/system/libroot/posix/malloc_hoard2/wrapper.cpp | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/system/libroot/posix/malloc_hoard2/arch-specific.cpp b/src/system/libroot/posix/malloc_hoard2/arch-specific.cpp index 688b602f6e..20f4cdf913 100644 --- a/src/system/libroot/posix/malloc_hoard2/arch-specific.cpp +++ b/src/system/libroot/posix/malloc_hoard2/arch-specific.cpp @@ -79,8 +79,6 @@ __init_after_fork(void) sHeapBase); exit(1); } - - hoardLockInit(sHeapLock, "heap"); } diff --git a/src/system/libroot/posix/malloc_hoard2/wrapper.cpp b/src/system/libroot/posix/malloc_hoard2/wrapper.cpp index c5e8c43c1a..acc0c80e9f 100644 --- a/src/system/libroot/posix/malloc_hoard2/wrapper.cpp +++ b/src/system/libroot/posix/malloc_hoard2/wrapper.cpp @@ -262,6 +262,8 @@ __heap_before_fork(void) static processHeap *pHeap = getAllocator(); for (int i = 0; i < pHeap->getMaxThreadHeaps(); i++) pHeap->getHeap(i).lock(); + + static_cast(pHeap)->lock(); } void __init_after_fork(void); @@ -273,6 +275,8 @@ __heap_after_fork_child(void) static processHeap *pHeap = getAllocator(); for (int i = 0; i < pHeap->getMaxThreadHeaps(); i++) pHeap->getHeap(i).initLock(); + + pHeap->initLock(); } @@ -282,6 +286,8 @@ __heap_after_fork_parent(void) static processHeap *pHeap = getAllocator(); for (int i = 0; i < pHeap->getMaxThreadHeaps(); i++) pHeap->getHeap(i).unlock(); + + static_cast(pHeap)->unlock(); }