aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/heap.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2021-10-26 17:53:08 +0200
committerCorinna Vinschen <corinna@vinschen.de>2021-10-26 18:47:22 +0200
commit44a79a6eca3d322020dda0919023d78dda129d4d (patch)
treec1241dc7277a6f5ce52d22a56d30948d40866669 /winsup/cygwin/heap.cc
parent23b1400f83a5f64dfab60cba2e25b0d858f44b5c (diff)
downloadnewlib-44a79a6eca3d322020dda0919023d78dda129d4d.zip
newlib-44a79a6eca3d322020dda0919023d78dda129d4d.tar.gz
newlib-44a79a6eca3d322020dda0919023d78dda129d4d.tar.bz2
Cygwin: convert malloc lock to SRWLOCK
Per https://cygwin.com/pipermail/cygwin-developers/2021-October/012429.html, we may encounter a crash when starting multiple threads during process startup (here: fhandler_fifo::fixup_after_{fork,exec}) which in turn allocate memory via malloc. The problem is concurrent usage of malloc before the malloc muto has been initialized. To fix this issue, convert the muto to a SRWLOCK and make sure it is statically initalized. Thus, malloc can be called as early as necessary and malloc_init is only required to check for user space provided malloc. Note that this requires to implement a __malloc_trylock macro to be called from fork. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin/heap.cc')
-rw-r--r--winsup/cygwin/heap.cc1
1 files changed, 0 insertions, 1 deletions
diff --git a/winsup/cygwin/heap.cc b/winsup/cygwin/heap.cc
index b839c8c..f27f81b 100644
--- a/winsup/cygwin/heap.cc
+++ b/winsup/cygwin/heap.cc
@@ -230,7 +230,6 @@ user_heap_info::init ()
debug_printf ("heap base %p, heap top %p, heap size %ly (%lu)",
base, top, chunk, chunk);
page_const--;
- // malloc_init ();
}
#define pround(n) (((size_t)(n) + page_const) & ~page_const)