2011-04-04 Jon TURNEY * dll_init.cc (load_after_fork): Add some debug output... * environ.cc (parse_thing): ... controlled by 'forkdebug' setting Index: winsup/cygwin/dll_init.cc =================================================================== --- winsup.orig/cygwin/dll_init.cc 2011-04-02 21:40:02.000000000 +0100 +++ winsup/cygwin/dll_init.cc 2011-04-03 18:47:09.781250000 +0100 @@ -29,6 +29,7 @@ dll_list dlls; static bool dll_global_dtors_recorded; +bool fork_debug = FALSE; /* Run destructors for all DLLs on exit. */ void @@ -307,6 +308,8 @@ above, the second LoadLibrary will not execute its startup code unless it is first unloaded. */ HMODULE h = LoadLibraryExW (d->name, NULL, DONT_RESOLVE_DLL_REFERENCES); + if (fork_debug) + system_printf("LoadLibrary %W @ %p (pass %d)", d->name, h, i); if (!h) system_printf ("can't reload %W, %E", d->name); @@ -332,7 +335,11 @@ } if (h == d->handle) - break; /* Success */ + { + if (fork_debug) + system_printf("successfully mapped %W @ %p", d->name, d->handle); + break; /* Success */ + } if (i > 1) /* We tried to relocate the dll and it failed. */ @@ -344,6 +351,8 @@ load into the same address space. In the "forked" process, the second DLL always loads into a different location. So, block all of the memory up to the new load address and try again. */ + if (fork_debug) + system_printf("reserve_upto %p to try to force it to load there", d->handle); reserve_upto (d->name, (DWORD) d->handle); /* Dll *still* loaded in the wrong place. This can happen if it @@ -352,6 +361,8 @@ preferred address and try again. */ if (i > 0) { + if (fork_debug) + system_printf("reserved_at %p to try to force it to load elsewhere", h); preferred_block = reserve_at(d->name, (DWORD)h); } } Index: winsup/cygwin/environ.cc =================================================================== --- winsup.orig/cygwin/environ.cc 2011-04-02 22:26:44.000000000 +0100 +++ winsup/cygwin/environ.cc 2011-04-02 22:28:10.937500000 +0100 @@ -37,6 +37,7 @@ bool reset_com = false; static bool envcache = true; static bool create_upcaseenv = false; +extern bool fork_debug; static char **lastenviron; @@ -605,6 +606,7 @@ {"tty", {NULL}, set_process_state, NULL, {{0}, {PID_USETTY}}}, {"upcaseenv", {&create_upcaseenv}, justset, NULL, {{false}, {true}}}, {"winsymlinks", {&allow_winsymlinks}, justset, NULL, {{false}, {true}}}, + {"forkdebug", {&fork_debug}, justset, NULL, {{false}, {true}}}, {NULL, {0}, justset, 0, {{0}, {0}}} };