[Bug 45213] Multiple applications using Microsoft Detours library crash on startup after compiling Wine with GCC 8.x+ and -O2 (GOT/PIC code emitted at function entry)(Microsoft Visual Studio 201x, Visual Assist plugin)

wine-bugs at winehq.org wine-bugs at winehq.org
Wed May 1 05:01:33 CDT 2019


https://bugs.winehq.org/show_bug.cgi?id=45213

Anastasius Focht <focht at gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
           Keywords|                            |download
            Summary|wine 3.7 can run VC +       |Multiple applications using
                   |visual assist, but wine 3.8 |Microsoft Detours library
                   |can not. or maybe gcc       |crash on startup after
                   |version related             |compiling Wine with GCC
                   |                            |8.x+ and -O2 (GOT/PIC code
                   |                            |emitted at function
                   |                            |entry)(Microsoft Visual
                   |                            |Studio 201x, Visual Assist
                   |                            |plugin)
          Component|-unknown                    |build-env
                URL|                            |https://web.archive.org/web
                   |                            |/20190501003029/http://down
                   |                            |loadfiles.idera.com/WholeTo
                   |                            |mato/VA_X_Setup2331_0.exe
         Resolution|---                         |FIXED
                 CC|                            |focht at gmx.net
      Fixed by SHA1|                            |8f732c66ab37b54c30d63c74f78
                   |                            |22ba1d4f04996

--- Comment #5 from Anastasius Focht <focht at gmx.net> ---
Hello folks,

this is now fixed by following commits:

*
https://source.winehq.org/git/wine.git/commitdiff/8f732c66ab37b54c30d63c74f7822ba1d4f04996
("makefiles: Build with -fno-PIC on i386.")

*
https://source.winehq.org/git/wine.git/commitdiff/8039941c52758113955d376bd7b6b6e1e5b5f76c
("makefiles: Also pass -fPIC flag when linking.")

Thanks Zebediah and Alexandre.

And, yes it was indeed caused by GCC 8.x emitting GOT/PIC register load code at
various function entries.

You didn't specify which version of the plugin and MS Visual Studio you used.
Please *always* provide this information, it's important for
reproducing/investigation.

I took MS Visual Studio 2010 and Visual Assist 10.9.x, assuming the same
underlying issue is present with other versions as well.

https://web.archive.org/web/20190501003029/http://downloadfiles.idera.com/WholeTomato/VA_X_Setup2331_0.exe 

In fact it's not only the plugin but also MS Visual Studio itself which hooks
several registry APIs (advapi32.RegXXX), suffering from same problem.

--- snip ---
$ pwd
/home/focht/.wine/drive_c/Program Files/Microsoft Visual Studio
10.0/Common7/IDE

$ WINEDEBUG=+loaddll,+process,+seh wine ./devenv.exe
...
00a1:trace:seh:raise_exception code=c0000005 flags=0 addr=0x7e9d20f1
ip=7e9d20f1 tid=00a1
00a1:trace:seh:raise_exception  info[0]=00000000
00a1:trace:seh:raise_exception  info[1]=6804c060
00a1:trace:seh:raise_exception  eax=680460f0 ebx=0034f77c ecx=0034f518
edx=0034f758 esi=00000000 edi=00000000
00a1:trace:seh:raise_exception  ebp=0034f508 esp=0034f4d0 cs=0023 ds=002b
es=002b fs=0063 gs=006b flags=00010202
00a1:trace:seh:call_stack_handlers calling handler at 0x7903d7bf code=c0000005
flags=0
00a1:trace:seh:call_stack_handlers handler at 0x7903d7bf returned 1
00a1:trace:seh:call_stack_handlers calling handler at 0x7903d894 code=c0000005
flags=0
00a1:trace:seh:call_stack_handlers handler at 0x7903d894 returned 1 
...
--- snip ---

Wine's advapi32.RegEnumKeyExW:

--- snip ---
7E9D20B0  E9 72F962B1   JMP 30001A27          ; trampoline -> does GOT/PIC load
7E9D20B5  05 4B5F0500   ADD EAX,55F4B         ; continuation
7E9D20BA  8D4C24 04     LEA ECX,[ESP+4]
7E9D20BE  83E4 F0       AND ESP,FFFFFFF0
7E9D20C1  FF71 FC       PUSH DWORD PTR DS:[ECX-4]
7E9D20C4  55            PUSH EBP
7E9D20C5  89E5          MOV EBP,ESP
7E9D20C7  57            PUSH EDI
7E9D20C8  56            PUSH ESI
7E9D20C9  53            PUSH EBX
7E9D20CA  51            PUSH ECX
7E9D20CB  83EC 28       SUB ESP,28
7E9D20CE  8B39          MOV EDI,DWORD PTR DS:[ECX]
7E9D20D0  8B71 04       MOV ESI,DWORD PTR DS:[ECX+4]
7E9D20D3  8B59 08       MOV EBX,DWORD PTR DS:[ECX+8]
7E9D20D6  8B51 14       MOV EDX,DWORD PTR DS:[ECX+14]
7E9D20D9  897D E4       MOV DWORD PTR SS:[EBP-1C],EDI
7E9D20DC  8B79 18       MOV EDI,DWORD PTR DS:[ECX+18]
7E9D20DF  8975 E0       MOV DWORD PTR SS:[EBP-20],ESI
7E9D20E2  8B71 10       MOV ESI,DWORD PTR DS:[ECX+10]
7E9D20E5  895D DC       MOV DWORD PTR SS:[EBP-24],EBX
7E9D20E8  8B59 0C       MOV EBX,DWORD PTR DS:[ECX+0C]
7E9D20EB  8955 D8       MOV DWORD PTR SS:[EBP-28],EDX
7E9D20EE  8B51 1C       MOV EDX,DWORD PTR DS:[ECX+1C]
7E9D20F1  F680 705F0000 TEST BYTE PTR DS:[EAX+5F70],08 ; GOT data ref, *boom*
...
--- snip ---

Like many other products/projects, a variant/fork of
https://github.com/Microsoft/Detours seems to be used.

--- snip ---
$ pwd
/home/focht/.wine/drive_c/Program Files/Microsoft Visual Studio
10.0/Common7/IDE

$ strings -e l devenv.exe | grep -i detour
Adding detour rule %d: from HKLM
Detour to HKCU
Adding detour rule %d: from HKCU
Detour rule to HKCU
AppId stopped registry detouring
AppId setting up registry detouring
AppId starting registry detouring
VsDetour: matched (%s): %s
--- snip ---

--- quote ---
Microsoft Research Detours Package

Detours is a software package for monitoring and instrumenting API calls on
Windows. Detours has been used by many ISVs and is also used by product teams
at Microsoft. Detours is now available under a standard open source license
(MIT). This simplifies licensing for programmers using Detours and allows the
community to support Detours using open source tools and processes.
--- quote ---

I'm not resolving as dupe of bug 45199 here since the task to identify
gazillion of win32 API to be "decorated" with DECLSPEC_HOTPATCH would have
turned that ticket into an endless story meta-ticket = mess. Everyone would
have joined in "me too", requesting "DECLSPEC_HOTPATCH for app X/game Y". Even
more worse, later commits that inlined debug trace facility would have caused
regressions again. Also that ticket has been listed in official release notes,
cited in many Internet forums/blogs, specific commits cherry-picked to Wine
stable branches etc. We don't want to alter/invalidate all that information
retroactively.

I'm using this ticket to target the standard MS Detours lib/engine (including
derivatives/forks) and resolve it here.

$ wine --version
wine-4.7-66-g8039941c52

Regards

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.



More information about the wine-bugs mailing list