Cygwin Python/PIL TCL/TK fork rebase solution

Robin Walker rdhw@cam.ac.uk
Tue Jan 16 17:50:00 GMT 2007


--On 16 January 2007 04:58 -0800 Brian Dessent wrote:

> Because in order to emulate fork(), Cygwin has to be able to re-execute
> the binary and have it load with the same memory layout.  If there are
> DLLs that overlap and need remapping by the OS then the memory layout
> becomes non-deterministic.  If Cygwin cannot create a child process with
> the same memory layout as the parent, then it cannot fork and you get
> the "unable to remap" error.
>
> Also note that this explains why binaries that dynamically load modules
> at runtime with dlopen() (such as Perl, Python, Apache, ...) are
> particular likely to be affected by this whereas if you are just running
> ordinary binaries that do no dynamic loading you almost never have to
> mess with rebasing.  Specifically, if a process loads modules at runtime
> and those modules need to be relocated by the OS then the memory layout
> depends now on countless details of the execution of the script or the
> logic flow of the binary.  Or put differently, the Windows process image
> loader (i.e. the thing that loads a .exe and all DLLs that it was linked
> against at link time) is relatively deterministic and repeatable, so you
> can get away with unbased DLLs if there is no runtime loading since the
> memory layout is still somewhat repeatably reproducable.

Brian,

Thanks for the explanations.  So, if I've understood things correctly, the 
difficulty boils down to cloning a parent process's address space layout 
within that of a child, which includes ensuring that DLLs appear at the 
same base within both processes.

For this to be the problem it appears to be, I'm guessing that there must 
be some shortcoming in the Windows APIs in this area when compared with 
facilities available within other Posix-compliant OSs.

How does Linux deal with the same issues of having libraries (or whatever 
are logically equivalent to DLLs) potentially linked at different bases in 
the two address spaces?

-- 
Robin Walker (Junior Bursar), Queens' College, Cambridge CB3 9ET, UK
rdhw@cam.ac.uk  http://www.queens.cam.ac.uk/  Tel:+44 1223 335528
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pkcs7-signature
Size: 4031 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20070116/a0902c96/attachment.p7s>


More information about the Cygwin mailing list