diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index e4931a286..e553c015a 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -296,7 +296,10 @@ frok::parent (volatile char * volatile stack_here) si.lpReserved2 = (LPBYTE) &ch; si.cbReserved2 = sizeof (ch); - bool locked = __malloc_trylock (); + /* NEVER, EVER, call a function which in turn calls malloc&friends while this + malloc lock is active! */ + __malloc_lock (); + bool locked = true; /* Remove impersonation */ cygheap->user.deimpersonate (); @@ -308,8 +311,7 @@ frok::parent (volatile char * volatile stack_here) ch.silentfail (!*with_forkables); /* fail silently without forkables */ - tmp_pathbuf tp; - PSECURITY_ATTRIBUTES sa = (PSECURITY_ATTRIBUTES) tp.w_get (); + PSECURITY_ATTRIBUTES sa = (PSECURITY_ATTRIBUTES) alloca (1024); if (!sec_user_nih (sa, cygheap->user.saved_sid (), well_known_authenticated_users_sid, PROCESS_QUERY_LIMITED_INFORMATION)) diff --git a/winsup/cygwin/local_includes/cygmalloc.h b/winsup/cygwin/local_includes/cygmalloc.h index 73a2f060b..5e1fe8154 100644 --- a/winsup/cygwin/local_includes/cygmalloc.h +++ b/winsup/cygwin/local_includes/cygmalloc.h @@ -32,7 +32,6 @@ extern "C" void __set_ENOMEM (); #elif defined (__INSIDE_CYGWIN__) # define __malloc_lock() AcquireSRWLockExclusive (&mallock) -# define __malloc_trylock() TryAcquireSRWLockExclusive (&mallock) # define __malloc_unlock() ReleaseSRWLockExclusive (&mallock) extern SRWLOCK NO_COPY mallock; void malloc_init ();