WineHQ
Bug Tracking Database – Bug 12757

 Bugzilla

 

Last modified: 2014-03-07 14:12:54 UTC  

Europa Universalis Rome crashes on startup (D3DXLoadSurfaceFromFileInMemory must not unconditionally call CoUninitialize(), different COM threading model used)

Bug 12757 - Europa Universalis Rome crashes on startup (D3DXLoadSurfaceFromFileInMemory must not unconditionally call CoUninitialize(), different COM threading model used)
Europa Universalis Rome crashes on startup (D3DXLoadSurfaceFromFileInMemory m...
Status: CLOSED FIXED
AppDB: Show Apps affected by this bug
Product: Wine
Classification: Unclassified
Component: d3d
0.9.60
x86 Linux
: P2 normal
: ---
Assigned To: Mr. Bugs
http://www.gamershell.com/download_24...
: download
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2008-04-23 10:57 UTC by Jonas Aaberg
Modified: 2014-03-07 14:12 UTC (History)
7 users (show)

See Also:
Regression SHA1:
Fixed by SHA1: 8226a187d63e3d355127cf1db830a4281132a598
Distribution: ---
Staged patchset:


Attachments
Start-up print outs of EU Rome - Full game. (8.91 KB, text/plain)
2008-04-23 10:57 UTC, Jonas Aaberg
Details
EU Rome start up. (3.56 KB, text/plain)
2008-04-24 11:54 UTC, Jonas Aaberg
Details
Start-up print outs of EU Rome - Full game. WINEDEBUG=+d3d,+d3d9 (557.21 KB, application/octet-stream)
2008-08-08 01:33 UTC, Jonas Aaberg
Details
WINEDEBUG=+d3d +d3d9 of Rome 1.3 (690.84 KB, application/octet-stream)
2008-09-13 03:39 UTC, Jonas Aaberg
Details
Terminal output (8.87 KB, text/plain)
2011-01-22 17:53 UTC, Trygve Vea
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonas Aaberg 2008-04-23 10:57:21 UTC
Created attachment 12414 [details]
Start-up print outs of EU Rome - Full game.

Both the full Europa Universalis Rome game and demo crashes at start-up.
I guess when the main menu is about to be loaded.

Both the game and the demo needs the msvcp60.dll in the same directory as
the main .exe file and a copy of d3dx9_36.dll in the windows/system32 

Probably they also require the videomemory registry variable to be set.
Comment 1 Jonas Aaberg 2008-04-24 11:54:19 UTC
Created attachment 12442 [details]
EU Rome start up.


(Old log was with native d3dx9_36.dll - sorry about that.)
This is with wine's d3dx9_36.dll.so:

It looks like two functions are missing.
--
wine: Call from 0x7ee23620 to unimplemented function d3dx9_36.dll.D3DXCreateFragmentLinker, aborting
wine: Call from 0x7ee23620 to unimplemented function d3dx9_36.dll.D3DXCreateFragmentLinkerEx, aborting
--
Comment 2 Jonas Aaberg 2008-04-24 11:58:07 UTC
The demo of EU Rome shows the same behaviour. It can be downloaded here:

http://www.gamershell.com/download_24442.shtml
Comment 3 Austin English 2008-04-25 21:22:41 UTC
Confirming in git.
Comment 4 Jonas Aaberg 2008-05-04 08:18:25 UTC
Still valid for 0.9.61
Comment 5 Clerc Mathias 2008-05-13 01:29:32 UTC
Also affecting Armed Assault. See :
http://forum.winehq.org/viewtopic.php?p=5455
Comment 6 Jonas Aaberg 2008-08-08 01:30:29 UTC
The original error message is gone in wine 1.1.2, but the game still crashes
at start-up. Attaching new log with WINEDEBUG=+d3d,+d3d9

Comment 7 Jonas Aaberg 2008-08-08 01:33:09 UTC
Created attachment 15344 [details]
Start-up print outs of EU Rome - Full game. WINEDEBUG=+d3d,+d3d9
Comment 8 Jonas Aaberg 2008-08-08 01:46:33 UTC
Ok, I think I've messed it up partly.
Rome Demo, 1.0 and 1.1 needs this D3DXCreateFragmentLinker call,
while Rome 1.2 does not.
Still all versions seems to crash at the same "spot" from a user
point of view. Just before the main screen should be displayed.
Comment 9 Jonas Aaberg 2008-09-13 03:39:35 UTC
Created attachment 16067 [details]
WINEDEBUG=+d3d +d3d9 of Rome 1.3

Start-up and crash of EU Rome v1.3
Comment 10 Jonas Aaberg 2008-09-13 03:40:11 UTC
Still valid for wine 1.1.4
Comment 11 Jonas Aaberg 2008-09-22 13:15:27 UTC
Still valid for wine 1.1.5
Comment 12 Radosław Ciechowski 2009-01-21 13:25:55 UTC
Game runs with d3dx9_36.dll and sound driver switched to OSS (which results in no sound in game for me, I guess turning sound off could be other workaround to run the game). VideoMemorySize is also needed, without it game crashes when loading graphics.

I tested versions 1.0 and 1.3, both run with above settings. I also installed expansion pack - Vae Victis, after that game crashes, but after installing MS Visual C++ 2005 SP1 with winetricks (sh winetricks vcrun2005sp1) game runs again.

Tested with Wine 1.1.13. I didnt have time to test gameplay for more than a few minutes, but game runs after some workarounds. I will add report to AppDB when I will have more time for longer tests.
Comment 13 Jonas Aaberg 2009-02-14 01:20:23 UTC
I close this bug entry, sicne I've managed to run the game as well.
I set the status to fixed.
Comment 14 Vitaliy Margolen 2009-02-14 12:11:50 UTC
Native DLLs are not a valid fix.
Comment 15 Pavel Ondračka 2009-09-01 09:41:13 UTC
1.1.28 still has this bug.
Comment 16 Trygve Vea 2011-01-22 17:53:28 UTC
Created attachment 32949 [details]
Terminal output

Still crashes in wine 1.3.12
Comment 17 Jerome Leclanche 2011-04-29 12:18:36 UTC
Please retest in a fresh wineprefix in today's git or in wine-1.3.19 when it's out, and attach an updated terminal output.
Comment 18 lfz 2012-07-17 23:50:06 UTC
Still present for wine 1.5.8
Comment 19 Adam Bolte 2014-02-08 19:53:57 UTC
Still present for wine 1.7.12 (tested with ArmA Gold in a clean wineprefix).
Comment 20 Anastasius Focht 2014-02-23 13:26:13 UTC
Hello folks,

confirming - although this bug has been recycled at least once for different issues.

The game uses a multi-threaded apartment on its main thread.
Multiple Wine components/API create apartment-threaded COM inproc servers on the same thread (dsound, d3dx, ...).

The caller needs to be aware of this situation (RPC_E_CHANGED_MODE) in order to avoid messing up the coinit refcount.
The visible part is the infamous 'Attempt to change threading model of this apartment from multi-threaded to apartment threaded' message in terminal.

Relevant part of trace log:

The game creates multi-threaded apartment and quartz instance:

--- snip ---
0025:Call ole32.CoInitializeEx(00000000,0000000c) ret=00897417
...
0025:Ret  ole32.CoInitializeEx() retval=00000000 ret=00897417
...
0025:Call ole32.CoCreateInstance(00a37470,00000000,00000003,00a37420,00e454d8) ret=008317a7
...
0025:Call KERNEL32.LoadLibraryExW(0033ee8e L"C:\\windows\\system32\\quartz.dll",00000000,00000008) ret=7eb6a6cb 
...
0025:Ret  PE DLL (proc=0x7d2c1b70,module=0x7d210000 L"quartz.dll",reason=PROCESS_ATTACH,res=(nil)) retval=1
0025:Ret  KERNEL32.LoadLibraryExW() retval=7d210000 ret=7eb6a6cb
...
0025:Ret  ole32.CoCreateInstance() retval=00000000 ret=008317a7
--- snip ---

Wine uses multiple COM servers on the same thread with apartment threading model:

--- snip ---
...
0025:Call dsound.DirectSoundCreate8(00000000,00de1880,00000000) ret=0082f977 
...
0025:Call ole32.CoInitialize(00000000) ret=7e2ce081
0025:err:ole:CoInitializeEx Attempt to change threading model of this apartment from multi-threaded to apartment threaded
0025:Ret  ole32.CoInitialize() retval=80010106 ret=7e2ce081
0025:Call ole32.CoCreateInstance(7e2e27d8,00000000,00000001,7e2e27a8,0033efa8) ret=7e2ce0b6 
...
--- snip ---

The problematic one:

--- snip ---
...
0025:trace:d3dx:D3DXLoadSurfaceFromFileInMemory dst_surface 0xb34afa8, dst_palette (nil), dst_rect (null), src_data 0x1570000, src_data_size 65580, src_rect (null), filter 0x1, color_key 0x00000000, src_info (nil).
0025:trace:d3dx:D3DXGetImageInfoFromFileInMemory (0x1570000, 65580, 0x33ea64)
0025:Call ole32.CoInitializeEx(00000000,00000002) ret=7ed82a47
0025:err:ole:CoInitializeEx Attempt to change threading model of this apartment from multi-threaded to apartment threaded
0025:Ret  ole32.CoInitializeEx() retval=80010106 ret=7ed82a47
0025:Call ole32.CoCreateInstance(7ed9ed1c,00000000,00000001,7ed9ed2c,0033e8cc) ret=7ed82a7f 
...
0025:trace:d3dx:D3DXLoadSurfaceFromMemory (0xb34afa8, (nil), (null), 0xb361c10, 0x16, 512, (nil), (0,0)-(128,128) 0x1, 0x00000000) 
...
0025:Call ole32.CoUninitialize() ret=7ed84242
0025:Call quartz.DllCanUnloadNow() ret=7eb6c1c3
0025:Call rpcrt4.NdrDllCanUnloadNow(7d30bab8) ret=7d2633fd
0025:Ret  rpcrt4.NdrDllCanUnloadNow() retval=00000000 ret=7d2633fd
0025:Ret  quartz.DllCanUnloadNow() retval=00000000 ret=7eb6c1c3
0025:Call KERNEL32.FreeLibrary(7d210000) ret=7eb6aa42
0025:Call PE DLL (proc=0x7d2c1b70,module=0x7d210000 L"quartz.dll",reason=PROCESS_DETACH,res=(nil))
0025:Ret  PE DLL (proc=0x7d2c1b70,module=0x7d210000 L"quartz.dll",reason=PROCESS_DETACH,res=(nil)) retval=1
0025:Call PE DLL (proc=0x7dcc9d1c,module=0x7dcb0000 L"msvfw32.dll",reason=PROCESS_DETACH,res=(nil))
0025:Ret  PE DLL (proc=0x7dcc9d1c,module=0x7dcb0000 L"msvfw32.dll",reason=PROCESS_DETACH,res=(nil)) retval=1
0025:Call PE DLL (proc=0x7cd1c3bc,module=0x7cc60000 L"comctl32.dll",reason=PROCESS_DETACH,res=(nil)) 
...
--- snip ---

At this point 'quartz.dll' is unloaded from memory but the game still holds COM class/iface references!

The crash is a late manifestation, it tries to call quartz.BasicAudio_put_Volume() with the PE image already gone.

Wine code like D3DXGetImageInfoFromFileInMemory() does it right, taking CoInitializeEx() result into account.
The COM threading model used might be still questionable.

Source: http://source.winehq.org/git/wine.git/blob/fa8a0dc7f61715a093a3b2e4453e843a4129476e:/dlls/d3dx9_36/surface.c#l1023

--- snip ---
1023 HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface,
1024        const PALETTEENTRY *pDestPalette, const RECT *pDestRect, const void *pSrcData, UINT SrcDataSize,
1025        const RECT *pSrcRect, DWORD dwFilter, D3DCOLOR Colorkey, D3DXIMAGE_INFO *pSrcInfo)
1026 {
...
1081     CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
1082
1083     if (FAILED(CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, &IID_IWICImagingFactory, (void**)&factory)))
1084         goto cleanup_err;
...
1180 cleanup_err:
1181     if (factory)
1182         IWICImagingFactory_Release(factory);
1183
1184     CoUninitialize();
...
--- snip ---

With that bug fixed it runs farther - and crashes again due to another d3dx9_36 insufficiency.

$ sha1sum Rome_Demo.exe
57e1fc8f2a1b8eeb0a1ccff218010eb828b00159  Rome_Demo.exe

$ du -sh Rome_Demo.exe
308M	Rome_Demo.exe

$ wine --version
wine-1.7.13-27-ge610713

Regards
Comment 21 Anastasius Focht 2014-02-26 02:02:47 UTC
Hello folks,

this is fixed by commit http://source.winehq.org/git/wine.git/commitdiff/8226a187d63e3d355127cf1db830a4281132a598

Thanks Matteo

Regards
Comment 22 Alexandre Julliard 2014-03-07 14:12:54 UTC
Closing bugs fixed in 1.7.14.


Privacy Policy
If you have a privacy inquiry regarding this site, please write to [email protected]

Hosted By CodeWeavers