This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Why does windows have such probs with dynamically loaded libs?


On 05/31/2011 05:18 PM, Linda Walsh wrote:
> Other than the stock answer of poor design, it seems loading a
> dynamically linked library at run-time shouldn't be a difficult task.

Poor design of Windows, not of cygwin.

> When Cygwin forks, how different is it from linux (other than stock
> answer of 'alot'),  i.e.  Does it create a new process and load the same
> static libs in, then have problems with dynamically loaded libs because
> they aren't recorded in the static binary?

Windows does _not_ have a native copy-on-write fork operation.  Linux
does.  When Linux forks, it merely needs mark all pages as
copy-on-write, then both the parent and the child share the same memory
image until one or the other execs and gives up that memory.  When
cygwin forks, it must manually hand-copy every single page of memory
from the parent into the child, including pages that can't normally be
copied by user space apps but are instead allocated by Windows (such as
dlls).  How?  By loading the same dlls in the child as in the parent,
and _hoping_ that windows loads them at the same address as the parent.

> Does cygwin actually copy, or attempt to setup COW pages that are not
> from static libs?   If so, wouldn't that catch dynamically loaded libs?

Windows doesn't support COW pages between a parent process and its
spawned child, at least not in the windows subsystem.  And the
documentation of the various subsystems lacking to the point that cygwin
has no way of reproducing the subsystem setup utilized by Interix for
its fork implementation (Interix doesn't have to care about interaction
with the windows subsystem).  So yes, cygwin really is stuck with
copying data, and for the data not directly manageable by user space,
cygwin has to go to great lengths to circumvent random behaviors
introduced by newer windows versions to try to get dlls loaded into the
same location.

> This may be complete insanity, but given the low level of support of MS's
> own Unix subsystem, I wonder if they might be persuaded (if it was
> desired) to lend more help or hooks for cygwin to do its magic reliably. 

Put yourself in Microsoft's shoes - why would you want to make it easier
for free software to replace your proprietary software?  Once you answer
that question, then you can see why it is unlikely that Cygwin will ever
have enough weight to convince MS to make our lives easier.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]