newlib/winsup/cygwin
Corinna Vinschen 33297d810d Cygwin: dlfcn: Fix reference counting
The original dll_init code was living under the wrong assumption that
dll_dllcrt0_1 and in turn dll_list::alloc will be called for each
LoadLibrary call.  The same wrong assumption was made for
cygwin_detach_dll/dll_list::detach called via FreeLibrary.

In reality, dll_dllcrt0_1 gets only called once at first LoadLibrary
and cygwin_detach_dll once at last FreeLibrary.

In effect, reference counting for DLLs was completely broken after fork:

  parent:
    l1 = dlopen ("lib1");  // LoadLibrary, LoadCount = 1
    l2 = dlopen ("lib1");  // LoadLibrary, LoadCount = 2

    fork ();               // LoadLibrary in the child, LoadCount = 1!
      child:
        dlclose (l1);      // FreeLibrary actually frees the lib
        x = dlsym (l2);    // SEGV

* Move reference counting to dlopen/dlclose since only those functions
  have to keep track of loading/unloading DLLs in the application context.

* Remove broken accounting code from dll_list::alloc and dll_list::detach.

* Fix error handling in dlclose.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-21 14:31:03 +01:00
..
include Belatedly bump Cygwin DLL version to 2.8.0 2017-03-10 20:50:35 +01:00
lib
libc
math
regex
release Cygwin: dlfcn: Fix reference counting 2017-03-21 14:31:03 +01:00
DevNotes
Makefile.in
ROADMAP
aclocal.m4
advapi32.cc
analyze_sigfe
assert.cc
autogen.sh
autoload.cc
automode.c
binmode.c
child_info.h
collate.h
common.din
config.h.in
configure
configure.ac
cpuid.h
crt0.c
ctype.cc
cxx.cc
cygerrno.h
cygheap.cc
cygheap.h
cygheap_malloc.h
cyglsa.h
cygmagic
cygmalloc.h
cygserver.h
cygserver_ipc.h
cygserver_msg.h
cygserver_pwdgrp.h
cygserver_sem.h
cygserver_setpwd.h
cygserver_shm.h
cygthread.cc
cygthread.h
cygtls.cc
cygtls.h
cygtls_padsize.h
cygwait.cc
cygwait.h
cygwin-cxx.h
cygwin-shilka
cygwin.ldif
cygwin.sc.in
cygwin_version.h
cygxdr.cc
cygxdr.h
dcrt0.cc
debug.cc
debug.h
devices.cc
devices.h
devices.in
dir.cc
dlfcn.cc Cygwin: dlfcn: Fix reference counting 2017-03-21 14:31:03 +01:00
dll_init.cc Cygwin: dlfcn: Fix reference counting 2017-03-21 14:31:03 +01:00
dll_init.h
dllfixdbg
dtable.cc
dtable.h
environ.cc
environ.h
errno.cc
exception.h
exceptions.cc
exec.cc
external.cc
fcntl.cc
fenv.cc
fhandler.cc
fhandler.h
fhandler_clipboard.cc
fhandler_console.cc
fhandler_dev.cc
fhandler_disk_file.cc
fhandler_dsp.cc
fhandler_fifo.cc
fhandler_floppy.cc
fhandler_mailslot.cc
fhandler_netdrive.cc
fhandler_nodevice.cc
fhandler_proc.cc
fhandler_process.cc
fhandler_procnet.cc
fhandler_procsys.cc
fhandler_procsysvipc.cc
fhandler_random.cc
fhandler_raw.cc
fhandler_registry.cc
fhandler_serial.cc
fhandler_socket.cc
fhandler_tape.cc
fhandler_termios.cc
fhandler_tty.cc
fhandler_virtual.cc
fhandler_virtual.h
fhandler_windows.cc
fhandler_zero.cc
flock.cc
fork.cc
gcrt0.c
gendef
gendevices
gentls_offsets
glob.cc
glob_pattern_p.cc
globals.cc
gmon.c
gmon.h
grp.cc
heap.cc
heap.h
hires.h
hookapi.cc
how-autoload-works.txt
how-cygheap-works.txt
how-cygtls-works.txt
how-fhandlers-work.txt
how-signals-work.txt
how-spawn-works.txt
how-startup-shutdown-works.txt
how-to-debug-cygwin.txt
how-vfork-works.txt
i686.din
init.cc
ioctl.cc
ipc.cc
kernel32.cc
lc_era.h
lc_msg.h
ldap.cc
ldap.h
libstdcxx_wrapper.cc
localtime.cc
lsearch.cc
malloc.cc
malloc_wrapper.cc
math.h
mcount.c
mcountFunc.S
miscfuncs.cc
miscfuncs.h
mkglobals_h
mkimport
mkstatic
mktemp.cc
mkvers.sh
mmap.cc
mmap_helper.h
mount.cc
mount.h
msg.cc
mtinfo.h
net.cc
netdb.cc
nfs.cc
nfs.h
nlsfuncs.cc
ntdll.h
ntea.cc
ntsecapi.h
passwd.cc
path.cc
path.h
pathfinder.h
perprocess.h
pinfo.cc
pinfo.h
pipe.cc
poll.cc
posix_ipc.cc
profil.c
profil.h
pseudo-reloc.cc
pthread.cc
pwdgrp.h
quotactl.cc
random.cc
registry.cc
registry.h
regparm.h
resource.cc
scandir.cc
sched.cc
sec_acl.cc
sec_auth.cc
sec_helper.cc
sec_posixacl.cc
sec_posixacl.h
security.cc
security.h
select.cc
select.h
sem.cc
setlsapwd.cc
shared.cc
shared_info.h
shm.cc
signal.cc
sigproc.cc
sigproc.h
smallprint.cc
sortdin
spawn.cc
speclib
spinlock.h
strace.cc
strfuncs.cc
string.h
strsep.cc
strsig.cc
sync.cc
sync.h
syscalls.cc
sysconf.cc
syslog.cc
termios.cc
textmode.c
textreadmode.c
thread.cc
thread.h
timer.cc
times.cc
tls_pbuf.cc
tls_pbuf.h
tlsoffsets.h
tlsoffsets64.h
tmpbuf.h
tty.cc
tty.h
tz_posixrules.h
uinfo.cc
uname.cc
update-copyright
userinfo.h
vstrlist.h
wait.cc
wchar.h
wincap.cc
wincap.h
window.cc
winf.cc
winf.h
wininfo.h
winlean.h
winsup.h
winver.rc
x86_64.din