libc/winsup/CONTRIBUTORS
David Allsopp 226f69422a Preserve order of dlopen'd modules in dll_list::topsort
This patch alters the behaviour of dll_list::topsort to preserve the
order of dlopen'd units.

The load order of unrelated DLLs is reversed every time fork is called,
since dll_list::topsort finds the tail of the list and then unwinds to
reinsert items. My change takes advantage of what should be undefined
behaviour in dll_list::populate_deps (ndeps non-zero and ndeps and deps
not initialised) to allow the deps field to be initialised prior to the
call and appended to, rather than overwritten.

All DLLs which have been dlopen'd have their deps list initialised with
the list of all previously dlopen'd units. These extra dependencies mean
that the unwind preserves the order of dlopen'd units.

The motivation for this is the FlexDLL linker used in OCaml. The FlexDLL
linker allows a dlopen'd unit to refer to symbols in previously dlopen'd
units and it resolves these symbols in DllMain before anything else has
initialised (including the Cygwin DLL). This means that dependencies may
exist between dlopen'd units (which the OCaml runtime system
understands) but which Windows is unaware of. During fork, the
process-level table which FlexDLL uses to get the symbol table of each
DLL is copied over but because the load order of dlopen'd DLLs is
reversed, it is possible for FlexDLL to attempt to access memory in the
DLL before it has been loaded and hence it fails with an access
violation. Because the list is reversed on each call to fork, it means
that a subsequent call to fork puts the DLLs back into the correct
order, hence "even" invocations of fork work!

An interesting side-effect is that this only occurs if the DLLs load at
their preferred base address - if they have to be rebased, then FlexDLL
works because at the time that the dependent unit is loaded out of
order, there is still in memory the "dummy" DONT_RESOLVE_DLL_REFERENCES
version of the dependency which, as it happens, will contain the correct
symbol table in the data section. For my tests, this initially appeared
to be an x86-only problem, but that was only because the two DLLs on x64
should have been rebased.

Signed-off-by: David Allsopp <david.allsopp@metastack.com>
2017-02-28 16:12:03 +01:00

95 lines
3.9 KiB
Plaintext

This file contains a list of individuals who submit their patches to
the Cygwin sources under 2-clause BSD license, as well as a list of
individuals who signed the former Cygwin Copyright Assignment up to 2016.
=========================================================================
2-clause BSD:
=========================================================================
Copyright (c) <YEAR>, <OWNER>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
=========================================================================
Individuals submitting their patches under 2-clause BSD:
David Allsopp David.Allsopp@cl.cam.ac.uk
Erik M. Bray erik.bray@lri.fr
=========================================================================
Individuals who signed the former Cygwin Copyright Assignment:
AJ Reins tbisp@qwest.net
Brian E. Dessent brian@dessent.net
Brian Kenneth Ford Brian.Ford@FlightSafety.com
Charles K. Moore keithmo@exmsft.com
Christian Franke franke@computer.org
Christian Lestrade christian.lestrade@free.fr
Christopher Faylor me@cgf.cx
Christopher January chris@atomice.net
Conrad Scott conrad.scott@dsl.pipex.com
Corinna Vinschen corinna@vinschen.de
Craig Iain McGeachie slapdau@yahoo.com.au
David Korn dave.korn.cygwin@gmail.com
Davis Euresti davie@alum.mit.edu
Dennis Vshivkov walrus@amur.ru
Elfyn McBratney elfyn@ubertales.co.uk
Eric Blake eblake@redhat.com
Ernie Coskrey ernie.coskrey@steeleye.com
Gerd Spalink Gerd.Spalink@t-online.de
Hartmut Honisch hhonisch@users.sourceforge.net
Igor Pechtchanski pechtcha@cs.nyu.edu
Jacek Trzcinski jacek@certum.pl
Jeffrey Eric Altman jaltman@openafs.org
Jerry D. Hedden jerry@hedden.us
Joe Loh joel@pivot3.com
Johan Rydberg johan@rydberg.com
Johannes Schindelin johannes.schindelin@gmx.de
John Hood cgull@glup.org
Jon Turney jon.turney@dronecode.org.uk
Yoni Londner yonihola2@gmail.com
Joseph H. Buehler jbuehler@hekimian.com
Joshua Daniel Franklin joshuadfranklin@yahoo.com
Ken Brown kbrown@cornell.edu
Lapo Luchini lapo@lapo.it
Lev Bishop lev.bishop@gmail.com
Max Kaehn slothman@electric-cloud.com
Micha Nelissen mdvpost@hotmail.com
Michael Haubenwallner michael.haubenwallner@ssi-schaefer.com
Nicholas S. Wourms nwourms@netscape.com
Pavel Yonkov Tsekov ptsekov@gmx.net
Peter Foley pefoley2@pefoley.com
Pierre A. Humblet phumblet@phumblet.no-ip.org
Robert G. Byrnes byrnes@curl.com
Ryan C. Gordon icculus@icculus.org
Sam Steingold sds@gnu.org
Stephen Cleary shammah@spamcop.net
Stephen Osborn bub@io.com
Takashi Yano takashi.yano@nifty.ne.jp
Thomas Pfaff tpfaff@gmx.net
Vaclav Haisman vhaisman@gmail.com
Yaakov Selkovitz yselkowi@redhat.com
Yitzchak Scott-Thoennes sthoenna@efn.org