mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-19 12:59:21 +08:00
44a79a6eca
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>
18 lines
455 B
C
18 lines
455 B
C
/* heap.h: Cygwin heap manager definitions.
|
|
|
|
This file is part of Cygwin.
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
details. */
|
|
|
|
#include "perprocess.h"
|
|
|
|
/* Heap management. */
|
|
void heap_init ();
|
|
|
|
#define inheap(s) \
|
|
(cygheap->user_heap.ptr && s \
|
|
&& ((char *) (s) >= (char *) cygheap->user_heap.base) \
|
|
&& ((char *) (s) <= (char *) cygheap->user_heap.top))
|