newlib-cygwin/winsup/cygwin/local_includes
Corinna Vinschen 717c36c0a4 Cygwin: fork: fix a potential hang in fork
while debugging a problem introduced in commit
63b503916d ("Cygwin: tls_pathbuf: Use Windows heap")
a hang in fork was encountered using the original implementation
of tls_pathbuf:

Using tmp_pathbuf inside the code block guarded by __malloc_trylock
may call malloc from tmp_pathbuf::w_get and thus trying to lock an
exclusive SRW lock recursively, which results in a deadlock.

Allocate a small SECURITY_ATTRIBUTES block on the stack rather than
allocating a 64K tmp_pathbuf.  This avoids the potential malloc call.

Drop the __malloc_trylock call entirely.  There must not be a malloc
call inside the frok::parent block guarded by __malloc_lock, and
just trying to lock is too dangerous inside fork while other threads
might actually chage the content of the heap.  Additionally, add a
comment frowning on malloc usage inside tis code block.

Fixes: 44a79a6eca ("Cygwin: convert malloc lock to SRWLOCK")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-29 12:25:24 +02:00
..
child_info.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
clock.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
collate.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
cpuid.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
create_posix_thread.h Cygwin: rename CygwinCreateThread to create_posix_thread 2022-08-10 18:06:28 +02:00
cygerrno.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
cygheap.h Cygwin: cwd: use SRWLOCK instead of muto 2022-08-23 12:09:44 +02:00
cygheap_malloc.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
cygmalloc.h Cygwin: fork: fix a potential hang in fork 2022-08-29 12:25:24 +02:00
cygserver.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
cygserver_ipc.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
cygserver_msg.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
cygserver_pwdgrp.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
cygserver_sem.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
cygserver_setpwd.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
cygserver_shm.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
cygthread.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
cygtls.h Cygwin: tls_pathbuf: Use Windows heap 2022-08-23 12:09:44 +02:00
cygwait.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
cygwin-cxx.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
cygwin_version.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
cygxdr.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
debug.h Cygwin: push missing change to debug.h 2022-08-22 14:53:30 +02:00
devices.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
dll_init.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
dtable.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
environ.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
errmap.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
exception.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
fhandler.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
fhandler_virtual.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
gcc_seh.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
gmon.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
heap.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
lc_era.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
lc_msg.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
ldap.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
loadavg.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
math.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
miscfuncs.h Cygwin: miscfuncs.h: fix comment 2022-08-19 15:51:49 +02:00
mmap_alloc.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
mmap_helper.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
mount.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
mqueue_types.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
mtinfo.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
nfs.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
ntdll.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
path.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
pathfinder.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
perprocess.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
pinfo.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
posix_timer.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
profil.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
pwdgrp.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
registry.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
sec_posixacl.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
security.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
select.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
shared_info.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
sigproc.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
spinlock.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
string.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
sync.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
thread.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
timerfd.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
tls_pbuf.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
tty.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
userinfo.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
vstrlist.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
wchar.h Cygwin: wchar.h: Fix comment 2022-08-20 20:27:37 +02:00
wincap.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
winf.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
wininfo.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
winlean.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00
winsup.h Cygwin: Reorganize cygwin source dir 2022-08-05 12:02:11 +02:00