https://bugs.winehq.org/show_bug.cgi?id=56196
Bug ID: 56196 Summary: Winelib DLLS using Wine APIs broken - constructor issue? Product: Wine Version: unspecified Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: loader Assignee: wine-bugs@winehq.org Reporter: john.rogers@oracle.com Distribution: ---
The .L__wine_spec_import_data_ptrs table doesn't appear to be initialized correctly starting in Wine 6 for winelib DLLs. Simplest sample I could come up with:
DLL source: (mydll.cpp)
#include <windows.h>
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason, LPVOID lpReserved) { return TRUE; }
extern "C" { void APIENTRY dllMethod(char *str) { // Create msgbox int msgbox = MessageBox(NULL, str, "The Caption", 0);
return; } }
SPEC file: (mydll.spec)
@ stdcall dllMethod(str)
Main EXE src: (main.c)
#include <windows.h>
extern void APIENTRY dllMethod(char *str);
// This function is the entry point for the program int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // Create msgbox int msgbox = MessageBox(NULL, "Text 1", "The Caption", 0); dllMethod("**** Text 2 ****"); msgbox = MessageBox(NULL, "Text 3", "The Caption", 0);
return 0; }
Compiled with following commands:
winegcc -m64 -shared -mwindows -o mydll.dll mydll.cpp mydll.spec winegcc -m64 -mwindows main.c mydll.dll.so
If you do this with Wine 4.0.4, running "wine64 a.out.so" will step through the 3 message boxes. If you do this with Wine 6 or greater, the first message box will be displayed, then the app will crash. The issue appears to be related to changes made in April 2020 ("winebuild: Don't use a constructor for dll modules either.") - the __wine_dll_register function appears to have been orphaned.
https://bugs.winehq.org/show_bug.cgi?id=56196
--- Comment #1 from Alexandre Julliard julliard@winehq.org --- Unfortunately the PE conversion has made it necessary to break compatibility with old Wine versions, so a Winelib binary built with Wine 4.0 is not going to run on more recent Wine, it will need a rebuild.
https://bugs.winehq.org/show_bug.cgi?id=56196
--- Comment #2 from John Rogers john.rogers@oracle.com --- That is essentially my question. With the recompilation of this sample, I get the crash. Is there some other step that needs to be done to get the .L__wine_spec_import_data_ptrs table initialized at runtime? (The crash is the result of the "jmp *.L__wine_spec_import_data_ptrs..." trampoline to the actual implementation)
https://bugs.winehq.org/show_bug.cgi?id=56196
--- Comment #3 from Alexandre Julliard julliard@winehq.org --- Ah sorry I misread the example. You'll need to load the library explicitly with LoadLibrary, or import it at the Windows level by building an import library for it.