summaryrefslogtreecommitdiffstats
path: root/newlib/libc/stdlib/system.c
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2017-03-21 14:30:24 +0100
committerCorinna Vinschen <corinna@vinschen.de>2017-03-21 14:31:03 +0100
commit33297d810d9033ffca661b8f9158116602615dd7 (patch)
tree94a85b260190f4badca35cd5f899d0a3e402bb3d /newlib/libc/stdlib/system.c
parent33c7b2b544a96ee443728f9558ce07a13e05f1e8 (diff)
downloadcygnal-33297d810d9033ffca661b8f9158116602615dd7.tar.gz
cygnal-33297d810d9033ffca661b8f9158116602615dd7.tar.bz2
cygnal-33297d810d9033ffca661b8f9158116602615dd7.zip
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>
Diffstat (limited to 'newlib/libc/stdlib/system.c')
0 files changed, 0 insertions, 0 deletions