dxvk: Some special DLL load address cause DXVK crash on illegal instruction (UD2)

I’m using DXVK 2.5 on Win10 22H2. I found if DXVK’s d3d9.dll loaded at some special addresses (e.g. 0x6FE90000), it will crash game with illegal instruction (UD2). Some other addresses (like 0x6EED0000) can cause game exit with code 3, and some addesses will operate normally. My quick analysis shows, the problem might related to https://github.com/doitsujin/dxvk/blob/56b7c8cd41ea17c0656f9485730fea5d55b3db62/src/d3d9/d3d9_common_texture.cpp#L404

I created a small sample program which can trigger this throw:

	if (FAILED(g_pd3dDevice->CreateTexture(256, 256, 9, D3DUSAGE_AUTOGENMIPMAP, D3DFMT_A4R4G4B4, D3DPOOL_DEFAULT, &g_pTexture, NULL))) {
		MessageBox(NULL, L"that's ok!", L"Textures.exe", MB_OK);
	}

Instead of returning an error code, dxvk’s d3d9.dll crashed the application.

(1) exception string in lower left dump window: 1_throw (2) continue, and it crashes on ud2 2_crash (3) d3d9.dll is loaded at 0x6FE90000 3_modules

About how to create a d3d9.dll which always loads at 0x6FE90000

(1) use editbin.exe to relocate it to 0x6FE90000:

editbin /rebase:base=0x6FE90000 d3d9.dll

(2) use hex editor to add IMAGE_FILE_RELOCS_STRIPPED to FileHeader.Characteristics of d3d9.dll IMAGE_FILE_RELOCS_STRIPPED

For your convenience, the EXE, DLL and log files is here:

bug.zip

System information

  • GPU: NVIDIA
  • Driver: 553.24.0
  • Wine version: Windows 10
  • DXVK version: 2.5

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (3 by maintainers)

Most upvoted comments

The mingw-w64 update is now out in the regular Arch repo

@zhangboyang Is the issue supposed to show out of the box when using the files provided in your archive? It is running fine for me here through wine using the d3d9.dll you shipped.

Either way i have done some poking and the Arch mingw-w64 packages have moved maintainer as a result. gcc version 14.2.0 is currently sitting in staging getting some testing. Thank you for reporting the problem

Thanks for testing @qinlili23333, and thanks for providing information about ArchLinux @Blisto91. I finally figured out what’s happening. It’s this bug: Exception handling broken for 32-bit Windows. This bug affected GCC 13.1.0 and it was fixed in GCC 13.2.0. Unfortunately, ArchLinux’s mingw-w64-gcc is exactly 13.1.0, which is buggy. I have no idea of why ArchLinux has a lower version of mingw than Ubuntu LTS (13.2.0 on 24.04). It seems mingw is not actively maintained in ArchLinux? At least it received no updates for almost one year. @doitsujin I suggest migrate to another toolchain for future builds (at least temporarily until ArchLinux fixed their toolchain). It would be appreciated if providing both mingw builds and MSVC builds. MSVC redist dependency can be eliminated by linking to static C/C++ library. MSVC (and clang) also has a advantage: address sanitizer can be enabled.

By the way, if anybody interested, here is a dirty fix for this problem: just use your favorite hex editor, search for adjacent bytes and replace 0x25 with 0x48: fix