public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: fork: reserve dynloaded dll areas earlier
@ 2019-03-28 9:13 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2019-03-28 9:13 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=023c107a22ebd2f540fa3f4888535aad32839fe2
commit 023c107a22ebd2f540fa3f4888535aad32839fe2
Author: Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
Date: Tue Mar 26 17:38:36 2019 +0100
Cygwin: fork: reserve dynloaded dll areas earlier
In dll_crt0_0, both threadinterface->Init and sigproc_init allocate
windows object handles using unpredictable memory regions, which may
collide with dynamically loaded dlls when they were relocated.
Diff:
---
winsup/cygwin/dcrt0.cc | 6 ++++++
winsup/cygwin/fork.cc | 6 ------
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 11edcdf..fb726a7 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -632,6 +632,12 @@ child_info_fork::handle_fork ()
if (fixup_mmaps_after_fork (parent))
api_fatal ("recreate_mmaps_after_fork_failed");
+
+ /* We need to occupy the address space for dynamically loaded dlls
+ before we allocate any dynamic object, or we may end up with
+ error "address space needed by <dll> is already occupied"
+ for no good reason (seen with some relocated dll). */
+ dlls.reserve_space ();
}
bool
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index 74ee9ac..7e1c089 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -136,12 +136,6 @@ frok::child (volatile char * volatile here)
{
HANDLE& hParent = ch.parent;
- /* NOTE: Logically this belongs in dll_list::load_after_fork, but by
- doing it here, before the first sync_with_parent, we can exploit
- the existing retry mechanism in hopes of getting a more favorable
- address space layout next time. */
- dlls.reserve_space ();
-
sync_with_parent ("after longjmp", true);
debug_printf ("child is running. pid %d, ppid %d, stack here %p",
myself->pid, myself->ppid, __builtin_frame_address (0));
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-03-28 9:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-28 9:13 [newlib-cygwin] Cygwin: fork: reserve dynloaded dll areas earlier Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).