XRenderFindDisplay crash / user32 winex11 initialisation order problem

Peter Oberndorfer kumbayo84 at arcor.de
Fri Dec 8 15:31:17 CST 2006


Hi,
today i wanted to create a test for CreateCompatibleDC so i created a exe with this content [1]
just to find out it crashes wine inside XRenderFindDisplay [2]

The reason is that the CreateCompatibleDC call in gdi executes LoadLibrary winex11.drv
which in turn also loads user32.dll, because winex11.drv links to it.
Then in DllMain user32 registers some builtin classes which causes it to call into winex11.
But at this point DllMain of winex11 had no chance to execute and XRenderQueryExtension gets passed a
NULL pointer which makes it unhappy.

Unfortunately i have no idea how to properly solve this problem :-(
* Use UserClientDllInitialize for initializing user32 stuff as the comment above DllMain mentions it?
* I tried linking gdi32 to user32(windows seems to do that) and inserted a dummy
IsCharAlphaA('c'); to make sure it is *really* linked :-)
And it does not crash anymore, but i don't know if i break any assumptions with that.
Also i think it is preferable to defer loading the driver until it is really needed.
If you have a better idea of how to fix this please tell me.

Greetings Peter

1: simplified version, compile with winegcc foo.c -lgdi32
#include <windows.h>
int main(int argc, char ** argv){
CreateCompatibleDC(NULL);
}

2: see attachment
-------------- next part --------------
Backtrace:
=>1 0x7e987b4d XRenderFindDisplay+0xbd() in libxrender.so.1 (0x0034f0f4)
  2 0x7e9889bd XRenderQueryExtension+0x1d() in libxrender.so.1 (0x0034f104)
  3 0x7ec510e3 X11DRV_XRender_Init+0x4f3() [/home/kumbayo/src/wine-git_compile/dlls/winex11.drv/xrender.c:203] in winex11 (0x0034f184)
  4 0x7ec25a08 X11DRV_CreateDC+0x138(hdc=0x198, pdev=0x156910, driver=0x34f210, device=0x0, output=0x0, initData=0x0) [/home/kumbayo/src/wine-git_compile/dlls/winex11.drv/init.c:92] in winex11 (0x0034f1c4)
  5 0x7edb41d0 CreateDCW+0x100(driver=<is not available>, device=0x0, output=0x0, initData=0x0) [/home/kumbayo/src/wine-git_compile/dlls/gdi32/dc.c:646] in gdi32 (0x0034f474)
  6 0x7e9d2b2f CreateIconFromResourceEx+0x45f(bits=0x7ea74648, cbSize=0x134, bIcon=0x0, dwVersion=0x30000, width=0x20, height=0x20, cFlag=0x8040) [/home/kumbayo/src/wine-git_compile/dlls/user32/cursoricon.c:727] in user32 (0x0034f524)
  7 0x7e9d34df CURSORICON_Load+0x34f(hInstance=0x7e9a0000, name=0x7f00, width=0x20, height=0x20, colors=0x1, fCursor=0x1, loadflags=0x8040) [/home/kumbayo/src/wine-git_compile/dlls/user32/cursoricon.c:995] in user32 (0x0034f584)
  8 0x7e9d3a4d LoadImageW+0x42d(hinst=<register not in topmost frame>, name=0x7f00, type=0x2, desiredx=0x20, desiredy=0x20, loadflags=<is not available>) [/home/kumbayo/src/wine-git_compile/dlls/user32/cursoricon.c:2282] in user32 (0x0034f634)
  9 0x7e9d4186 LoadImageA+0x56(hinst=0x0, name=0x7f00, type=0x2, desiredx=0x0, desiredy=0x0, loadflags=0x8040) [/home/kumbayo/src/wine-git_compile/dlls/user32/cursoricon.c:2211] in user32 (0x0034f714)
  10 0x7e9d4422 LoadCursorA+0x42(hInstance=0x0, name=0x7f00) [/home/kumbayo/src/wine-git_compile/dlls/user32/cursoricon.c:1720] in user32 (0x0034f744)
  11 0x7e9ca055 register_builtin+0x85(descr=<register not in topmost frame>) [/home/kumbayo/src/wine-git_compile/dlls/user32/class.c:381] in user32 (0x0034f774)
  12 0x7e9ca0ad CLASS_RegisterBuiltinClasses+0x1d() [/home/kumbayo/src/wine-git_compile/dlls/user32/class.c:408] in user32 (0x0034f784)
  13 0x7ea3e101 DllMain+0x181(inst=0x7e9a0000, reason=0x1, reserved=0x0) [/home/kumbayo/src/wine-git_compile/dlls/user32/user_main.c:229] in user32 (0x0034f804)
  14 0x7ea50f35 __wine_spec_dll_entry+0xb5(inst=0x7e9a0000, reason=<register not in topmost frame>, reserved=<register not in topmost frame>) [/home/kumbayo/src/wine-git_compile/dlls/winecrt0/dll_entry.c:40] in user32 (0x0034f824)
  15 0x7efb5845 call_dll_entry_point+0x15() in ntdll (0x0034f844)
  16 0x7efb6939 MODULE_InitDLL+0x179(wm=0x13ee50, reason=0x1, lpReserved=0x0) [/home/kumbayo/src/wine-git_compile/dlls/ntdll/loader.c:831] in ntdll (0x0034f8f4)
  17 0x7efb6ded process_attach+0x12d(wm=<register not in topmost frame>, lpReserved=0x0) [/home/kumbayo/src/wine-git_compile/dlls/ntdll/loader.c:901] in ntdll (0x0034f934)
  18 0x7efb6d32 process_attach+0x72(wm=<register not in topmost frame>, lpReserved=0x0) [/home/kumbayo/src/wine-git_compile/dlls/ntdll/loader.c:893] in ntdll (0x0034f974)
  19 0x7efb8f37 LdrLoadDll+0x87(path_name=0x13ec70, flags=0x0, libname=0x34fc10, hModule=0x34fbe4) [/home/kumbayo/src/wine-git_compile/dlls/ntdll/loader.c:1807] in ntdll (0x0034f9a4)
  20 0x7ee9f45b load_library+0x5b(libname=0x34fc10, flags=<register not in topmost frame>) [/home/kumbayo/src/wine-git_compile/dlls/kernel32/module.c:830] in kernel32 (0x0034fbf4)
  21 0x7ee9f65c LoadLibraryExW+0x4c(libnameW=<register not in topmost frame>, hfile=0x0, flags=0x0) [/home/kumbayo/src/wine-git_compile/dlls/kernel32/module.c:886] in kernel32 (0x0034fc24)
  22 0x7ee9f781 LoadLibraryExA+0x41(libname=0x34fd9c, hfile=0x0, flags=0x0) [/home/kumbayo/src/wine-git_compile/dlls/kernel32/module.c:866] in kernel32 (0x0034fc44)
  23 0x7ee9f7b9 LoadLibraryA+0x29(libname=0x34fd9c) [/home/kumbayo/src/wine-git_compile/dlls/kernel32/module.c:919] in kernel32 (0x0034fc64)
  24 0x7edb8530 DRIVER_load_driver+0x1c0(name=0x7edf2b00) [/home/kumbayo/src/wine-git_compile/dlls/gdi32/driver.c:253] in gdi32 (0x0034fdd4)
  25 0x7edb2aee CreateCompatibleDC+0x16e(hdc=0x0) [/home/kumbayo/src/wine-git_compile/dlls/gdi32/dc.c:744] in gdi32 (0x0034fe04)
  26 0x0040100e in createcompatibledc (+0x100e) (0x0034fe2c)
  27 0x004012d7 in createcompatibledc (+0x12d7) (0x0034ff08)
  28 0x7eeadbdb start_process+0xeb(arg=0x0) [/home/kumbayo/src/wine-git_compile/dlls/kernel32/process.c:820] in kernel32 (0x0034ffe8)
  29 0xb7e0c7b7 (0x00000000)


More information about the wine-devel mailing list