Hallo, I am trying to debug Xilinx webpack version 5.1. If I understand things right, the "ise" application crashed because it unloads a dll, but later still accesses this dll. This seems to happen, because during MODULE_InitDLL of the dll it calls a Loadlibrary on itself. As MODULE_InitDLL sets WINE_MODREF_MARKER, and the flow of execution in LoadLibrary checks for WINE_MODREF_MARKER before incrementing the RefCount, the refcount gets wrong and the application unloaded. Forcing the increment of RefCount in MODULE_LoadLibraryExA unconditional of WINE_MODREF_MARKER makes the application continue. Do we need the check for WINE_MODREF_MARKER in MODULE_LoadLibraryEx? Do we still need MODULE_LoadLibraryEx at all? Bye -- Uwe Bonnes bon(a)elektron.ikp.physik.tu-darmstadt.de Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt --------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
Uwe Bonnes <bon(a)elektron.ikp.physik.tu-darmstadt.de> writes:
This seems to happen, because during MODULE_InitDLL of the dll it calls a Loadlibrary on itself. As MODULE_InitDLL sets WINE_MODREF_MARKER, and the flow of execution in LoadLibrary checks for WINE_MODREF_MARKER before incrementing the RefCount, the refcount gets wrong and the application unloaded. Forcing the increment of RefCount in MODULE_LoadLibraryExA unconditional of WINE_MODREF_MARKER makes the application continue.
Do we need the check for WINE_MODREF_MARKER in MODULE_LoadLibraryEx?
Yes, this is needed for circular dependencies. But maybe we need to differentiate an explicit LoadLibrary from the implicit loading of dependencies. -- Alexandre Julliard julliard(a)winehq.com
"Alexandre" == Alexandre Julliard <julliard(a)winehq.com> writes:
Alexandre> Uwe Bonnes <bon(a)elektron.ikp.physik.tu-darmstadt.de> writes: >> This seems to happen, because during MODULE_InitDLL of the dll it >> calls a Loadlibrary on itself. As MODULE_InitDLL sets >> WINE_MODREF_MARKER, and the flow of execution in LoadLibrary checks >> for WINE_MODREF_MARKER before incrementing the RefCount, the refcount >> gets wrong and the application unloaded. Forcing the increment of >> RefCount in MODULE_LoadLibraryExA unconditional of WINE_MODREF_MARKER >> makes the application continue. >> >> Do we need the check for WINE_MODREF_MARKER in MODULE_LoadLibraryEx? Alexandre> Yes, this is needed for circular dependencies. But maybe we Alexandre> need to differentiate an explicit LoadLibrary from the Alexandre> implicit loading of dependencies. Is appended patch appropriate? If it finds WINE_MODREF_MARKER set in LoadLibraryEx, it corrects the Refcount and it allows decrementing the Refcounter to 1 (but not to 0) in MODULE_DecRefCount. At least xilinx webpack ise.exe now comes over thw first hurdle. Changelog: wine/loader/module.c: LoadLibraryExA, MODULE_DecRefCount Handle Refcounting for LoadLibrary/FreeLibrary Calls during MODULE_DllProcessAttach -- Uwe Bonnes bon(a)elektron.ikp.physik.tu-darmstadt.de Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt --------- Tel. 06151 162516 -------- Fax. 06151 164321 ---------- Index: wine/loader/module.c =================================================================== RCS file: /home/wine/wine/loader/module.c,v retrieving revision 1.165 diff -u -w -r1.165 module.c --- wine/loader/module.c 24 Sep 2002 18:29:39 -0000 1.165 +++ wine/loader/module.c 9 Oct 2002 08:18:19 -0000 @@ -1134,6 +1134,10 @@ SetLastError(ERROR_DLL_INIT_FAILED); wm = NULL; } + if(wm->flags & WINE_MODREF_MARKER) + /* Loadlibrary was called during MODULE_DllProcessAttach + We need to correct the refcount */ + wm->refCount++; } RtlLeaveCriticalSection( &loader_section ); @@ -1470,7 +1474,9 @@ { int i; - if ( wm->flags & WINE_MODREF_MARKER ) + if (( wm->flags & WINE_MODREF_MARKER ) && (wm->refCount <2)) + /* Inhibit unloading during MODULE_DllProcessAttach but expect a FreeLibrary call + during MODULE_DllProcessAttach */ return; if ( wm->refCount <= 0 )
participants (2)
-
Alexandre Julliard -
Uwe Bonnes