protonscr

CreateDXGIFactory crashes when DXVK linked as native lib

dxvkclosed
doitsujin/dxvk#5275 · opened 2025-10-17 by q4a · updated 2025-10-17 · 2 comments · github
Qq4a 2025-10-17 github

I would like to use DXVK+D3D11 as one of my renders for Linux game, but currently it crashes when I call CreateDXGIFactory before creating Window or creating D3D11 device.

Windows and old DXVK Native has no issue with my test examples.

Here is simple example that leads to crash:

#include <iostream>
#include <dxgi.h>
#ifdef _WIN32
#pragma comment (lib, "DXGI.lib")
#endif

int main() {
	IDXGIFactory* pFactory1 = nullptr;
	HRESULT hr1 = CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)(&pFactory1));
	if (SUCCEEDED(hr1))
	{
		std::cout << "Success on 1st CreateDXGIFactory" << std::endl;
	}

	IDXGIFactory* pFactory2 = nullptr;
	HRESULT hr2 = CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)(&pFactory1));
	if (SUCCEEDED(hr2))
	{
		std::cout << "Success on 2nd CreateDXGIFactory" << std::endl;
	}

	return 0;
}

Software information

It's custom engine, but here is full example with CI:
https://github.com/q4a/dxvk-test/tree/main

System information

  • GPU: AMD Radeon HD 8400 / R3 Series (RADV KABINI)
  • Driver: radv from mesa 25.2.4+git2510141528.adfcb467b89
  • Wine version: not used
  • DXVK version: tested both v2.6 and v2.7.1-189-g42a827ba

Log files

1st run is DXVK Native, 2nd - upstream DXVK.

q@mono:~/git/dxvk-test$ DXVK_WSI_DRIVER=SDL2 ./build/Ninja-Debug-Old/Debug/dxvk-test 
info:  Game: dxvk-test
info:  DXVK: v1.9.2
info:  Built-in extension providers:
info:    SDL2 WSI
info:  Enabled instance extensions:
info:    VK_KHR_get_surface_capabilities2
info:    VK_KHR_surface
info:    VK_KHR_xlib_surface
warn:  Skipping CPU adapter: llvmpipe (LLVM 20.1.8, 256 bits)
info:  AMD Radeon HD 8400 / R3 Series (RADV KABINI):
info:    Driver: 25.2.4
info:    Vulkan: 1.3.318
info:    Memory Heap[0]: 
info:      Size: 2828 MiB
info:      Flags: 0x0
info:      Memory Type[2]: Property Flags = 0x6
info:      Memory Type[5]: Property Flags = 0xe
info:      Memory Type[6]: Property Flags = 0xe
info:    Memory Heap[1]: 
info:      Size: 5657 MiB
info:      Flags: 0x1
info:      Memory Type[0]: Property Flags = 0x1
info:      Memory Type[1]: Property Flags = 0x1
info:      Memory Type[3]: Property Flags = 0x7
info:      Memory Type[4]: Property Flags = 0x7
Success on 1st CreateDXGIFactory
info:  Game: dxvk-test
info:  DXVK: v1.9.2
info:  Built-in extension providers:
info:    SDL2 WSI
info:  Enabled instance extensions:
info:    VK_KHR_get_surface_capabilities2
info:    VK_KHR_surface
info:    VK_KHR_xlib_surface
warn:  Skipping CPU adapter: llvmpipe (LLVM 20.1.8, 256 bits)
info:  AMD Radeon HD 8400 / R3 Series (RADV KABINI):
info:    Driver: 25.2.4
info:    Vulkan: 1.3.318
info:    Memory Heap[0]: 
info:      Size: 2828 MiB
info:      Flags: 0x0
info:      Memory Type[2]: Property Flags = 0x6
info:      Memory Type[5]: Property Flags = 0xe
info:      Memory Type[6]: Property Flags = 0xe
info:    Memory Heap[1]: 
info:      Size: 5657 MiB
info:      Flags: 0x1
info:      Memory Type[0]: Property Flags = 0x1
info:      Memory Type[1]: Property Flags = 0x1
info:      Memory Type[3]: Property Flags = 0x7
info:      Memory Type[4]: Property Flags = 0x7
Success on 2nd CreateDXGIFactory
q@mono:~/git/dxvk-test$ DXVK_WSI_DRIVER=SDL2 ./build/Ninja-Debug/Debug/dxvk-test 
info:  Game: dxvk-test
info:  DXVK: v2.7.1-189-g42a827ba
info:  Build: x86_64 clang 20.1.8
info:  Vulkan: Found vkGetInstanceProcAddr in libvulkan.so @ 0x72374b1bcd30
info:  Extension providers:
info:    Platform WSI
Segmentation fault (core dumped)

There is dxvk-test_dxgi.log, but it has same output.
I also has logs in CI:
I got err: SDL2 WSI: Failed to create dummy window. - with DXVK Native, but it;s ok.

And with upstream DXVK I got segmentation fault

Mmisyltoad 2025-10-17 github

Can you please provide a backtrace?

Qq4a 2025-10-17 github

Sorry for bothering you. It was my fault: backtrace showed that it call SDL2 and i tested this simple change and it works:

diff --git a/source.cpp b/source.cpp
index 31ce202..d873a71 100644
--- a/source.cpp
+++ b/source.cpp
@@ -2,9 +2,16 @@
 #include <dxgi.h>
 #ifdef _WIN32
 #pragma comment (lib, "DXGI.lib")
+#else
+#include <SDL2/SDL.h>
 #endif
 
 int main() {
+
+#ifndef _WIN32
+    SDL_InitSubSystem(SDL_INIT_EVENTS | SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER);
+#endif
+

So I just didn't call SDL_InitSubSystem.

If you still interesting - here is backtrace of old example:

Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
info:  Game: dxvk-test
info:  DXVK: v2.7.1-189-g42a827ba
info:  Build: x86_64 clang 20.1.8
info:  Vulkan: Found vkGetInstanceProcAddr in libvulkan.so @ 0x7ffff5aa8d30
info:  Extension providers:
info:    Platform WSI

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7e961e0 in ?? () from /lib/x86_64-linux-gnu/libSDL2-2.0.so.0
(gdb) bt
#0  0x00007ffff7e961e0 in ?? () from /lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#1  0x00007ffff703d8d8 in dxvk::wsi::Sdl2WsiDriver::getInstanceExtensions (this=0x5555555b7c20) at ../dxvk-src-upstream/src/wsi/sdl2/wsi_platform_sdl2.cpp:43
#2  0x00007ffff703bd70 in dxvk::wsi::getInstanceExtensions () at ../dxvk-src-upstream/src/wsi/wsi_platform.cpp:65
#3  0x00007ffff6f13c3d in dxvk::DxvkPlatformExts::getInstanceExtensions (this=0x7ffff7370558 <dxvk::DxvkPlatformExts::s_instance>) at ../dxvk-src-upstream/src/dxvk/dxvk_platform_exts.cpp:14
#4  0x00007ffff6eb4e83 in dxvk::DxvkInstance::initVulkanInstance (this=0x55555556b920, args=..., flags=...) at ../dxvk-src-upstream/src/dxvk/dxvk_instance.cpp:210
#5  0x00007ffff6eb3988 in dxvk::DxvkInstance::DxvkInstance (this=0x55555556b920, args=..., flags=...) at ../dxvk-src-upstream/src/dxvk/dxvk_instance.cpp:56
#6  0x00007ffff6eb31b6 in dxvk::DxvkInstance::DxvkInstance (this=0x55555556b920, flags=...) at ../dxvk-src-upstream/src/dxvk/dxvk_instance.cpp:20
#7  0x00007ffff6e671f6 in dxvk::Singleton<dxvk::DxvkInstance>::acquire<int> (this=0x7ffff7370b28 <dxvk::g_dxvkInstance>, constantArgs=0)
    at ../dxvk-src-upstream/src/dxgi/../util/util_singleton.h:24
#8  0x00007ffff6e64e60 in dxvk::DxgiFactory::DxgiFactory (this=0x5555555908e0, Flags=0) at ../dxvk-src-upstream/src/dxgi/dxgi_factory.cpp:82
#9  0x00007ffff6e6b68f in dxvk::createDxgiFactory (Flags=0, riid=..., ppFactory=0x7fffffffdad0) at ../dxvk-src-upstream/src/dxgi/dxgi_main.cpp:10
[#10](/issue/doitsujin/dxvk/10) 0x00007ffff6e6b8bf in CreateDXGIFactory (riid=..., ppFactory=0x7fffffffdad0) at ../dxvk-src-upstream/src/dxgi/dxgi_main.cpp:35
[#11](/issue/doitsujin/dxvk/11) 0x0000555555555191 in main () at /home/q/git/dxvk-test/source.cpp:9

Launch options