4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-29 18:40:25 +08:00
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

40 lines
1.1 KiB
Plaintext

What's new:
-----------
- New API: timingsafe_bcmp, timingsafe_memcmp
- New API: dladdr
What changed:
-------------
- cygcheck and strace now always generate output with Unix LF line endings,
rather than with DOS/Windows CR LF line endings.
- fork now preserves the load order of unrelated dlopen'd modules.
- pthread_cond_wait now acts like Linux and BSD: Resume waiting for the
condition variable as if it was not interrupted, rather than returning 0.
Bug Fixes
---------
- Fix a few problems which are the combined culprit of fork failing
when called recursively from a pthread.
Addresses: https://cygwin.com/ml/cygwin/2017-03/msg00113.html
- Fix potential buffer overflow in getrandom.
- Fix write(2) return value for writes > 2 GB.
- Workaround Windows NUL having the same problem for writes > 4 GB.
Addresses: https://cygwin.com/ml/cygwin/2017-03/msg00144.html
- Fix a potential crash in duplocale.
Addresses: https://sourceware.org/ml/newlib/2017/msg00166.html
- Fix dlopen/dlclose reference counting to make sure FreeLibrary isn't
called too early in forked process.
Addresses: https://cygwin.com/ml/cygwin/2017-03/msg00220.html