diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2021-10-26 17:53:08 +0200 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2021-10-26 18:47:22 +0200 |
commit | 44a79a6eca3d322020dda0919023d78dda129d4d (patch) | |
tree | c1241dc7277a6f5ce52d22a56d30948d40866669 /winsup/cygwin/dcrt0.cc | |
parent | 23b1400f83a5f64dfab60cba2e25b0d858f44b5c (diff) | |
download | newlib-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/dcrt0.cc')
-rw-r--r-- | winsup/cygwin/dcrt0.cc | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 6f4723b..f3d09c1 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -29,6 +29,7 @@ details. */ #include "shared_info.h" #include "cygwin_version.h" #include "dll_init.h" +#include "cygmalloc.h" #include "heap.h" #include "tls_pbuf.h" #include "exception.h" |