forked from git/git
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Labels
Description
[New msys2-runtime version] Cygwin: lock cygheap during fork
Cygwin: lock cygheap during fork
another thread may simultaneously be doing a cmalloc/cfree while the
cygheap is being copied to the child.
Addresses: https://cygwin.com/pipermail/cygwin/2025-September/258801.html
Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
(cherry picked from commit 8a5d39527f9a56d1a623e86d30af6b590fd1472d)
[New msys2-runtime version] Cygwin: spawn: Lock cygheap from refresh_cygheap() until child_copy()
Cygwin: spawn: Lock cygheap from refresh_cygheap() until child_copy()
...completion in child process because the cygheap should not be
changed to avoid mismatch between child_info::cygheap_max and
::cygheap_max. Otherwise, child_copy() might copy cygheap being
modified by other process.
In addition, to avoid deadlock, move close_all_files() for non-
Cygwin processes after unlocking cygheap, since close_all_files()
calls cfree(), which attempts to lock cygheap even when it's already
locked.
Fixes: 977ad5434cc0 ("* spawn.cc (spawn_guts): Call refresh_cygheap before creating a new process to ensure that cygheap_max is up-to-date.")
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
(cherry picked from commit 9b667234bfa6220dcca1afa1233a928d9100cfde)
[New msys2-runtime version] Cygwin: cygheap: Add lock()/unlock() method
Cygwin: cygheap: Add lock()/unlock() method
...so that cygheap can be locked/unlocked from outside of mm/cygheap.cc.
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
(cherry picked from commit aec6dc77a11b264fcac73b63ada701854fc62a22)