WineHQ
Bug Tracking Database – Bug 30745

 Bugzilla

 

Last modified: 2014-01-10 14:46:17 UTC  

GOG.com version of Soulbringer crashes on startup (GetModuleHandleExW needs to support GET_MODULE_HANDLE_EX_FLAG_PIN)

Bug 30745 - GOG.com version of Soulbringer crashes on startup (GetModuleHandleExW needs to support GET_MODULE_HANDLE_EX_FLAG_PIN)
GOG.com version of Soulbringer crashes on startup (GetModuleHandleExW needs t...
Status: CLOSED FIXED
AppDB: Show Apps affected by this bug
Product: Wine
Classification: Unclassified
Component: kernel32
1.5.4
x86 Linux
: P2 normal
: ---
Assigned To: Mr. Bugs
: patch
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2012-05-21 18:10 UTC by Fernando Martins
Modified: 2014-01-10 14:46 UTC (History)
4 users (show)

See Also:
Regression SHA1:
Fixed by SHA1: 9a6567d1a6161f331ae4e07f3bd2697875af3d74
Distribution: ---
Staged patchset:


Attachments
backtrace (9.36 KB, text/plain)
2012-05-21 18:10 UTC, Fernando Martins
Details
7zipped +relay,+seh,+tid log (uncompressed 4.6 MB) (74.55 KB, application/x-7z-compressed)
2012-05-28 05:54 UTC, Béla Gyebrószki
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fernando Martins 2012-05-21 18:10:14 UTC
see backtrace
Comment 1 Fernando Martins 2012-05-21 18:10:52 UTC
Created attachment 40258 [details]
backtrace
Comment 2 joaopa 2012-05-21 21:24:06 UTC
Try a native mfc42 dll.
Comment 3 Austin English 2012-05-21 22:15:12 UTC
(In reply to comment #2)
> Try a native mfc42 dll.

Wine doesn't provide one. It's already present:
> PE	5f400000-5f4f2000	Export          mfc42

otherwise it would've given an error during the dll import.
Comment 4 Béla Gyebrószki 2012-05-28 05:54:04 UTC
Created attachment 40312 [details]
7zipped +relay,+seh,+tid log (uncompressed 4.6 MB)

I can confirm the problem with the GOG.com version of the game.
Soulbringer.exe, which is the launcher/configuration tool for the game, crashes.
I see the same crash with previous Wine versions as well (1.1.35, 1.2.3, 1.4 etc)
Here I'm attaching a +relay debug log in case someone can find it useful.

I also have the DotEmu version of the game, and that version of Soulbringer.exe starts correctly in Wine (both versions need mfc42.dll)
The GOG.com version of the game contains additional patches, there are extra dlls in the game directory (e.g. patch.dll) used by Soulbringer.exe.
Comment 5 Pierre Etchemaite 2012-07-30 04:15:17 UTC
You can see intro video by launching SoulbringeVCnoeax.exe, but after that you get stuck on a slashscreen: the menu, or whatever is supposed to happen next, never appears.
Comment 6 Béla Gyebrószki 2012-07-31 10:24:40 UTC
(In reply to comment #5)
> You can see intro video by launching SoulbringeVCnoeax.exe, but after that you
> get stuck on a slashscreen: the menu, or whatever is supposed to happen next,
> never appears.

That's bug #24916. The problem here is with the launcher (Soulbringer.exe).

wine-1.5.9-294-g0316a1b
Comment 7 Anastasius Focht 2013-10-12 07:31:27 UTC
Hello folks,

confirming.
Bought the game for a few bucks just for analysis. 

In short: There is an in-process patcher dll that requires to stay in memory until the process exits (makes use of GET_MODULE_HANDLE_EX_FLAG_PIN flag which Wine doesn't implement).

--- snip ---
$ pwd
/home/focht/.wine/drive_c/Program Files/GOG.com/Soulbringer
...
$ WINEDEBUG=+tid,+seh,wine ./Soulbringer.exe
...
0009:trace:loaddll:load_native_dll Loaded L"C:\\Program Files\\GOG.com\\Soulbringer\\PATCH.dll" at 0x3c0000: native
0009:trace:loaddll:load_native_dll Loaded L"C:\\Program Files\\GOG.com\\Soulbringer\\data\\Stealth\\Render\\D3d6Lib.dll" at 0x10000000: native
...
0009:fixme:module:GetModuleHandleExW should pin refcount for 0x3c0000
...
0009:trace:loaddll:free_modref Unloaded module L"C:\\Program Files\\GOG.com\\Soulbringer\\data\\Stealth\\Render\\D3d6Lib.dll" : native
0009:trace:loaddll:free_modref Unloaded module L"C:\\Program Files\\GOG.com\\Soulbringer\\PATCH.dll" : native
...
0009:trace:loaddll:load_native_dll Loaded L"C:\\Program Files\\GOG.com\\Soulbringer\\PATCH.dll" at 0x3c0000: native
0009:trace:loaddll:load_native_dll Loaded L"C:\\Program Files\\GOG.com\\Soulbringer\\D3d7Lib.dll" at 0x10000000: native
...
0009:fixme:module:GetModuleHandleExW should pin refcount for 0x3c0000
...
0009:trace:loaddll:free_modref Unloaded module L"C:\\Program Files\\GOG.com\\Soulbringer\\D3d7Lib.dll" : native
0009:trace:loaddll:free_modref Unloaded module L"C:\\Program Files\\GOG.com\\Soulbringer\\PATCH.dll" : native
0009:trace:loaddll:free_modref Unloaded module L"C:\\windows\\system32\\dinput.dll" : builtin
0009:trace:loaddll:free_modref Unloaded module L"C:\\windows\\system32\\winmm.dll" : builtin
0009:trace:loaddll:free_modref Unloaded module L"C:\\windows\\system32\\msacm32.dll" : builtin
0009:trace:seh:raise_exception code=c0000005 flags=0 addr=0x3c2320 ip=003c2320 tid=0009
0009:trace:seh:raise_exception  info[0]=00000000
0009:trace:seh:raise_exception  info[1]=003c2320
0009:trace:seh:raise_exception  eax=00000000 ebx=7ea69ec2 ecx=0033f8f8 edx=0016ed6d esi=0033f8f8 edi=00000000
0009:trace:seh:raise_exception  ebp=0033ea68 esp=0033ea24 cs=0023 ds=002b es=002b fs=0063 gs=006b flags=00010206
0009:trace:seh:call_stack_handlers calling handler at 0x5f492e0a code=c0000005 flags=0
...
--- snip ---

When being loaded, "PATCH.dll" inserts hooks at several locations in main executable.
The game code eventually hits such a hook while the dll was already unloaded (not pinned in memory).

MSDN for GetModuleHandleEx(): http://msdn.microsoft.com/en-us/library/windows/desktop/ms683200%28v=vs.85%29.aspx

Source: http://source.winehq.org/git/wine.git/blob/c0e72bb3626a7ba8090ee07cc0aa88cd5c8b7f9e:/dlls/kernel32/module.c#l505

--- snip ---
505 BOOL WINAPI GetModuleHandleExW( DWORD flags, LPCWSTR name, HMODULE *module )
506 {
...
538     if (status == STATUS_SUCCESS)
539     {
540         if (flags & GET_MODULE_HANDLE_EX_FLAG_PIN)
541             FIXME( "should pin refcount for %p\n", ret );
542         else if (!(flags & GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT))
543             LdrAddRefDll( 0, ret );
544     }
...
554     return (status == STATUS_SUCCESS);
555 }
--- snip ---

$ du -sh setup_soulbringer.exe 
828M	setup_soulbringer.exe

$ sha1sum setup_soulbringer.exe 
5be1a70a24e37212bfeaa02a29d8d86af9cf2fca  setup_soulbringer.exe

$ wine --version
wine-1.7.4

Regards
Comment 8 Nikolay Sivov 2013-10-12 09:41:35 UTC
It looks like the best way is to use LdrGetDllHandleEx(), internally LdrAddRefDll() should be able to pin refcount.
Comment 9 Anastasius Focht 2013-10-14 18:02:13 UTC
Hello folks,

support for LdrAddRefDll( LDR_ADDREF_DLL_PIN, module) has been added:

http://source.winehq.org/git/wine.git/commitdiff/146ff49161fb35095ae9ac6f4c40281cd8f748f4

When the kernel32 part gets committed this bug will be fixed.

Regards
Comment 10 Nikolay Sivov 2013-10-15 01:32:04 UTC
An easy way to fix that is sent http://www.winehq.org/pipermail/wine-patches/2013-October/127577.html.
Comment 12 Anastasius Focht 2013-10-15 14:59:55 UTC
Hello folks,

the launcher now starts successfully.

Final commit: http://source.winehq.org/git/wine.git/commitdiff/9a6567d1a6161f331ae4e07f3bd2697875af3d74

This will also fix issues observed in other applications which depended on pinned modules like .NET CLR/apps (indicated by "fixme:module:GetModuleHandleExW should pin refcount" messages)

Thanks Nikolay

Regards
Comment 13 Fernando Martins 2013-10-15 16:55:25 UTC
for clarification: launcher starts but game gets stuck on title screen?
Comment 14 Anastasius Focht 2013-10-15 17:11:01 UTC
Hello,

--- quote ---
for clarification: launcher starts but game gets stuck on title screen?
--- quote ---

well this bug is about the launcher crashing on startup - which is fixed now.
You are free to report new bugs for other issues with the game.
Make sure you have searched Bugzilla prior to avoid duplicates.

Regards
Comment 15 Austin English 2013-10-16 02:49:44 UTC
(In reply to comment #12)
> Hello folks,
> 
> the launcher now starts successfully.
> 
> Final commit:
> http://source.winehq.org/git/wine.git/commitdiff/9a6567d1a6161f331ae4e07f3bd2697875af3d74
> 
> This will also fix issues observed in other applications which depended on
> pinned modules like .NET CLR/apps (indicated by
> "fixme:module:GetModuleHandleExW should pin refcount" messages)

Any tips on which apps to check? A quick bugzilla search shows 35 bugs like that, most of which are IE8/Silverlight related:

http://bugs.winehq.org/buglist.cgi?query_format=advanced&list_id=127508&field0-0-0=attach_data.thedata&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&type0-0-0=substring&value0-0-0=GetModuleHandleExW%20should%20pin%20refcount&product=Wine
Comment 16 Alexandre Julliard 2013-10-25 12:54:10 UTC
Closing bugs fixed in 1.7.5.
Comment 17 Alexandre Julliard 2014-01-10 14:46:17 UTC
Removing 1.6.x milestone from bugs included in 1.6.2.


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

Hosted By CodeWeavers