Search code examples
c++linuxsqlitemingwwine

Why does Wine 7.10+ hang when C++ program links statically with sqlite3?


Consider a C++ program:

#include <sqlite3.h>

int main(int argc, char**argv) {
  return 0;
}

void not_called() {
  sqlite3_initialize();
}

Compile, link, and run it:

$ x86_64-w64-mingw32-g++ -c -g -o augh.o augh.cpp
$ x86_64-w64-mingw32-g++ -static -fstack-protector -g -o augh.exe augh.o -lsqlite3
$ wine augh.exe

On Fedora 36, with

  • mingw64-gcc-c++-11.2.1-5.fc36.x86_64
  • wine-7.12-1.fc36.x86_64
  • mingw64-sqlite-static-3.36.0.0-3.fc36.noarch

and also previously with wine-7.10-2.fc36.x86_64, I consistently get this output:

[juckelman@midas augh]$ ./augh.exe 
002c:fixme:winediag:LdrInitializeThunk wine-staging 7.12 is a testing version containing experimental patches.
002c:fixme:winediag:LdrInitializeThunk Please mention your exact version when filing bug reports on winehq.org.
MESA-INTEL: warning: Haswell Vulkan support is incomplete
MESA-INTEL: warning: Haswell Vulkan support is incomplete
MESA-INTEL: warning: Haswell Vulkan support is incomplete
MESA-INTEL: warning: Haswell Vulkan support is incomplete
0080:err:x11drv:X11DRV_ChangeDisplaySettingsEx Failed to write L"\\\\.\\DISPLAY1" display settings to registry.
0080:err:system:NtUserChangeDisplaySettings Changing L"\\\\.\\DISPLAY1" display settings returned -3.
0080:err:explorer:initialize_display_settings Failed to initialize registry display settings for L"\\\\.\\DISPLAY1".
0114:err:sync:RtlpWaitForCriticalSection section 00000002DE99D010 "?" wait timed out in thread 0114, blocked by 0000, retrying (60 sec)

The final line repeats endlessly and the program never exits.

If I comment out sqlite3_initialize() (which is in a function that's never called!), I get this output:

[juckelman@midas augh]$ ./augh.exe 
002c:fixme:winediag:LdrInitializeThunk wine-staging 7.12 is a testing version containing experimental patches.
002c:fixme:winediag:LdrInitializeThunk Please mention your exact version when filing bug reports on winehq.org.
MESA-INTEL: warning: Haswell Vulkan support is incomplete
MESA-INTEL: warning: Haswell Vulkan support is incomplete
MESA-INTEL: warning: Haswell Vulkan support is incomplete
MESA-INTEL: warning: Haswell Vulkan support is incomplete
0080:err:x11drv:X11DRV_ChangeDisplaySettingsEx Failed to write L"\\\\.\\DISPLAY1" display settings to registry.
0080:err:system:NtUserChangeDisplaySettings Changing L"\\\\.\\DISPLAY1" display settings returned -3.
0080:err:explorer:initialize_display_settings Failed to initialize registry display settings for L"\\\\.\\DISPLAY1".
[juckelman@midas augh]$

The program exits successfully every time.

On Fedora 35 with

  • mingw64-gcc-c++-11.2.1-3.fc35.x86_64
  • wine-7.2-1.fc35.x86_64
  • mingw64-sqlite-static-3.36.0.0-2.fc35.noarch

the program exits successfully either way, regardless of the presence of sqlite3_initialize().

On Fedora 36, if I dynamically link with sqlite3 instead, the program also exits successfully.

What is going on here?


Solution

  • This no longer happens with Wine 7.22. The solution is to upgrade.