WineHQ
Bug Tracking Database – Bug 27282

 Bugzilla

 

Last modified: 2014-11-29 12:38:50 CST  

TDRABCSetup.exe hang on start up (FindWindowExW uses WM_GETTEXT to query for process' local window title text, leading to potential deadlock)

Bug 27282 - TDRABCSetup.exe hang on start up (FindWindowExW uses WM_GETTEXT to query for process' local window title text, leading to potential deadlock)
TDRABCSetup.exe hang on start up (FindWindowExW uses WM_GETTEXT to query for ...
Status: CLOSED FIXED
AppDB: Show Apps affected by this bug
Product: Wine
Classification: Unclassified
Component: user32
1.3.20
x86 Linux
: P2 normal
: ---
Assigned To: Qian Hong
http://www.95599.cn/update/down/TDRAB...
: download
: 30902 (view as bug list)
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2011-05-25 07:59 CDT by Qian Hong
Modified: 2014-11-29 12:38 CST (History)
4 users (show)

See Also:
Regression SHA1:
Fixed by SHA1: d5ba7451a34bcdd1af5734cfc320f52abc957258
Distribution: ---
Staged patchset:


Attachments
Log: winedbg backtrace all (24.11 KB, text/plain)
2011-09-26 04:33 CDT, Qian Hong
Details
Log: +relay trace, TDRABCSetup of abchina bank hang on start up (468.68 KB, application/x-gzip)
2012-01-14 04:15 CST, Qian Hong
Details
Patch: user32: Call WM_GETTEXT message procedure directly in GetWindowText. (1.62 KB, patch)
2014-11-11 12:29 CST, Qian Hong
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Qian Hong 2011-05-25 07:59:27 CDT
1. Download the installer 
$ wget http://www.95599.cn/update/down/TDRABCSetup.exe

2. start with wine:
$ wine TDRABCSetup.exe

there is no any output, also no any window display.

Typing Ctrl+C can not stop the program, the output is like below:

^Cfixme:console:CONSOLE_DefaultHandler Terminating process 8 on event 0
err:ntdll:RtlpWaitForCriticalSection section 0x338198 "?" wait timed out in thread 0020, blocked by 0009, retrying (60 sec)

Only wineserver -k can stop the program.
Comment 1 Qian Hong 2011-09-26 04:33:49 CDT
Created attachment 36569 [details]
Log: winedbg backtrace all

Still in wine1.3.28

Adding winedbg backtrace all log.
Comment 2 Qian Hong 2011-09-26 04:34:38 CDT
Update summary
Comment 3 Qian Hong 2012-01-14 04:15:58 CST
Created attachment 38347 [details]
Log: +relay trace, TDRABCSetup of abchina bank hang on start up
Comment 4 Qian Hong 2012-01-14 04:17:19 CST
Still in wine-1.3.36-223-gc7cc9a1
Comment 5 Anastasius Focht 2012-01-14 05:03:58 CST
Hello,

confirming.

It seems the installer looks for specific processes using window title match.

A second worker thread is spawned that calls FindWindow() and while the main thread waits for the worker to finish (without pumping messages).

Although the installer doesn't explicitly create a window up to this point, a hidden window has already been created as part of OLE init.

Wine's current FindWindow -> window list -> GetWindowText() logic uses SendMessage() if the window is created in same process.
This deadlocks here because the main thread is blocked, not pumping messages.

Relevant part of trace log:

--- snip ---
0024:Starting process L"Z:\\home\\focht\\Downloads\\TDRABCSetup.exe" (entryproc=0x403542)
0024:Call comctl32.InitCommonControls() ret=00403567
0024:Ret  comctl32.InitCommonControls() retval=68754b05 ret=00403567
0024:Call KERNEL32.SetErrorMode(00008001) ret=00403572
0024:Ret  KERNEL32.SetErrorMode() retval=00000000 ret=00403572
0024:Call ole32.OleInitialize(00000000) ret=00403579 
...
0024:Call user32.CreateWindowExW(00000000,7062df00 L"OleMainThreadWndClass 0x######## ",00000000,00000000,00000000,00000000,00000000,00000000,fffffffd,00000000,70540000,00000000) ret=7055e6f6 
...
0024:Ret  user32.CreateWindowExW() retval=00060052 ret=7055e6f6 
...
0024:Call KERNEL32.LoadLibraryExW(0040e0b0 L"C:\\users\\focht\\Temp\\nsm3ed0.tmp\\Plugin_ABC.dll",00000000,00000008) ret=0040218b 
...
0024:Ret  KERNEL32.LoadLibraryExW() retval=00370000 ret=0040218b 
...
0024:CALL Plugin_ABC.CloseGarbageWindows(00000000,00002004,00471000,0040a0a0,0040a000) ret=004021d8 
...
0024:Call KERNEL32.CreateThread(00000000,00000000,00372160,00000000,00000000,00000000) ret=00372222
0024:Ret  KERNEL32.CreateThread() retval=00000044 ret=00372222
0024:Call KERNEL32.WaitForSingleObject(00000044,ffffffff) ret=0037222b 
...
0025:Starting thread proc 0x372160 (arg=(nil))
0025:Call KERNEL32.GetSystemDefaultLangID() ret=00372167
0025:Ret  KERNEL32.GetSystemDefaultLangID() retval=00000409 ret=00372167
0025:Call user32.FindWindowW(00000000,00376438 L"Internet Banking of Agricultural Bank of China") ret=003721ae 

<deadlock here>
--- snip ---

Nice how they call their own stuff "garbage windows" ;-)

Debugger, creation of hidden window:

--- snip ---
Wine-dbg>bt
Backtrace:
=>0 0x682755cf WIN_CreateWindowEx+0x719(cs=0x33f98c, className="OleMainThreadWndClass 0x######## ", module=0x68850000, unicode=0x1) [/home/focht/projects/wine/wine-git/include/winbase.h:2540] in user32 (0x0033f974)
  1 0x68276413 CreateWindowExW+0x7d(exStyle=0, className="OleMainThreadWndClass 0x######## ", windowName=0x0(nil), style=0, x=0, y=0, width=0, height=0, parent=0xfffffffd, menu=(nil), instance=0x68850000, data=0x0(nil)) [/home/focht/projects/wine/wine-git/dlls/user32/win.c:1583] in user32 (0x0033f9c4)
  2 0x688696f6 apartment_createwindowifneeded+0x9c(apt=0x12a750) [/home/focht/projects/wine/wine-git/dlls/ole32/compobj.c:1195] in ole32 (0x0033fa34)
  3 0x68867760 apartment_get_or_create+0xff(model=0x2) [/home/focht/projects/wine/wine-git/dlls/ole32/compobj.c:391] in ole32 (0x0033fa84)
  4 0x68869ea8 CoInitializeEx+0x19d(lpReserved=0x0(nil), dwCoInit=0x2) [/home/focht/projects/wine/wine-git/dlls/ole32/compobj.c:1443] in ole32 (0x0033faf4)
  5 0x68894fdc OleInitialize+0x76(reserved=0x0(nil)) [/home/focht/projects/wine/wine-git/dlls/ole32/ole2.c:185] in ole32 (0x0033fb54)
Wine-dbg>info locals
0x682755cf WIN_CreateWindowEx+0x719: (0033f974)
	CREATESTRUCTW* cs=0x33f98c (parameterEBP)
	LPCWSTR className="OleMainThreadWndClass 0x######## " (parameterEBP)
	HINSTANCE module=0x68850000 (parameterEBP)
...
	HWND hwnd=0x2002c (localEBP)
	HWND parent=0x20034 (localEBP)
	HWND owner=(nil) (localEBP)
	HWND top_child=(nil) (localEBP)
	MDICREATESTRUCTW mdi_cs={szClass=0x0(nil), szTitle=0x0(nil), hOwner=(nil), x=0, y=0, cx=0, cy=0, style=0, lParam=0} (localEBP)
	CBT_CREATEWNDW cbtc={lpcs=(nil), hwndInsertAfter=(nil)} (localEBP)
	CREATESTRUCTW cbcs={lpCreateParams=0x0(nil), hInstance=(nil), hMenu=(nil), hwndParent=(nil), cy=0, cx=0, y=0, x=0, style=0, lpszName=0x0(nil), lpszClass=0x0(nil), dwExStyle=0} (localEBP)
	DWORD ret=0x24 (localEBP)
--- snip ---

Debugger, synchronous send message call to blocked main thread:

--- snip ---
Wine-dbg>bt
Backtrace:
=>0 0x68284ec3 send_message(info=0xe1e940, res_ptr=0xe1e96c, unicode=0x1) [/home/focht/projects/wine/wine-git/dlls/user32/message.c:3064] in user32 (0x00e1e978)
  1 0x682b685d GetWindowTextW+0x4e(hwnd=0x2002c, lpString="", nMaxCount=0x30) [/home/focht/projects/wine/wine-git/dlls/user32/win.c:2552] in user32 (0x00e1e998)
  2 0x682b4b1b FindWindowExW+0x15f(parent=(nil), child=(nil), className=0x0(nil), title="Internet Banking of Agricultural Bank of China") [/home/focht/projects/wine/wine-git/dlls/user32/win.c:1775] in user32 (0x00e1e9d8)
  3 0x682b4e05 FindWindowW+0x33(className=0x0(nil), title="Internet Banking of Agricultural Bank of China") [/home/focht/projects/wine/wine-git/dlls/user32/win.c:1843] in user32 (0x00e1e9f8)
  4 0x003421ae in plugin_abc (+0x21ad) (0x682b4dd1)
--- snip ---

Source: http://source.winehq.org/git/wine.git/blob/8f565eb6ae2663e2ef11342e85ce1cada1f6404c:/dlls/user32/win.c#l2544

--- snip ---
2547 INT WINAPI GetWindowTextW( HWND hwnd, LPWSTR lpString, INT nMaxCount )
2548 {
2549     if (!lpString) return 0;
2550 
2551     if (WIN_IsCurrentProcess( hwnd ))
2552         return (INT)SendMessageW( hwnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString );
2553 
2554     /* when window belongs to other process, don't send a message */
2555     if (nMaxCount <= 0) return 0;
2556     get_server_window_text( hwnd, lpString, nMaxCount );
2557     return strlenW(lpString);
2558 }
--- snip ---

$ sha1sum TDRABCSetup.exe 
07f5d29a22ac01ab4eebf6779001dc6794028066  TDRABCSetup.exe

$ wine --version
wine-1.3.37

Regards
Comment 6 Anastasius Focht 2013-12-05 09:17:26 CST
*** Bug 30902 has been marked as a duplicate of this bug. ***
Comment 7 Qian Hong 2013-12-06 07:13:24 CST
(In reply to comment #6)
> *** Bug 30902 has been marked as a duplicate of this bug. ***

Hi, could someone test http://source.winehq.org/patches/data/100929 with bug 30902? My motivation to test by myself was killed by 1 GB of downloading...

Thanks :p
Comment 8 Béla Gyebrószki 2013-12-06 08:42:15 CST
(In reply to comment #7)
> (In reply to comment #6)
> > *** Bug 30902 has been marked as a duplicate of this bug. ***
> 
> Hi, could someone test http://source.winehq.org/patches/data/100929 with bug
> 30902? My motivation to test by myself was killed by 1 GB of downloading...
> 
> Thanks :p

Your patch indeed fixes the startup issue in Arcania:Gothic 4.
Comment 9 Béla Gyebrószki 2013-12-07 12:17:01 CST
(In reply to comment #7)
> (In reply to comment #6)
> > *** Bug 30902 has been marked as a duplicate of this bug. ***
> 
> Hi, could someone test http://source.winehq.org/patches/data/100929 with bug
> 30902? My motivation to test by myself was killed by 1 GB of downloading...
> 
> Thanks :p

I came across a problem with your patch: you can't change the size of the virtual desktop in winecfg's graphics tab. When you enter a different resolution and click on <Apply>, resolution reverts to the default 800x600.
Comment 10 Qian Hong 2013-12-07 12:27:05 CST
(In reply to comment #9)
> (In reply to comment #7)
> > (In reply to comment #6)
> > > *** Bug 30902 has been marked as a duplicate of this bug. ***
> > 
> > Hi, could someone test http://source.winehq.org/patches/data/100929 with bug
> > 30902? My motivation to test by myself was killed by 1 GB of downloading...
> > 
> > Thanks :p
> 
> I came across a problem with your patch: you can't change the size of the
> virtual desktop in winecfg's graphics tab. When you enter a different
> resolution and click on <Apply>, resolution reverts to the default 800x600.

Nice test... Thanks GyB, I can confirm that, will investigate more.
Comment 11 Béla Gyebrószki 2014-08-26 11:34:23 CDT
Still an issue in 1.7.25
Comment 12 Qian Hong 2014-11-11 12:29:16 CST
Created attachment 49956 [details]
Patch: user32: Call WM_GETTEXT message procedure directly in GetWindowText.

Hi, could someone help to test the new attached patch?

Thanks!
Comment 13 Bruno Jesus 2014-11-11 18:58:31 CST
(In reply to Qian Hong from comment #12)
> Created attachment 49956 [details]
> Patch: user32: Call WM_GETTEXT message procedure directly in GetWindowText.
> 
> Hi, could someone help to test the new attached patch?
> 
> Thanks!

The patch works and the application starts as expected.
Comment 14 Sebastian Lackner 2014-11-11 20:12:31 CST
Even if the patch probably works, I don't think its the right solution to solve the issue. This patch has the disadvantage that now theoretically WM_GETTEXT messages can cause race-conditions with other WM_{SET,GET}TEXT messages on the main thread where the window was created.

Thats not a big problem for the default message handler, but other applications which install their own handler will crash then. Based on the information available online its perfectly fine that GetWindowText(...) sends a WM_GETTEXT message, so I would guess that the conclusion from Fochts analysis is actually wrong. Just search for "GetWindowText deadlock" and you'll find lots of people on Windows having the same problem.

I would assume that either:

* Windows only uses this behaviour if the wndproc procedure is really the default one, where Windows know that its threadsafe. Not sure if that fixes the issue for both affected apps though.

* The Ole window shouldn't be created so early

* FindWindowExW shouldn't use WM_GETTEXT <-- Thats what I would guess. Best way would be to write some tests where WM_GETTEXT doesn't match the window title that is known to the wineserver.
Comment 15 Sebastian Lackner 2014-11-12 01:03:41 CST
I have written a patchset including tests which seems to confirm my theory:

Patches:
https://github.com/wine-compholio/wine-staging/tree/master/patches/user32-FindWindowEx

Testbot:
https://newtestbot.winehq.org/JobDetails.pl?Key=10210

Could you guys please give it a try?

Please note that patch 2 also contains some tests for GetWindowText, and these tests seem to confirm that everything is right with the Wine implementation. Applying the patch from comment 12 or http://source.winehq.org/patches/data/100929 breaks the tests.
Comment 16 Qian Hong 2014-11-12 07:40:27 CST
(In reply to Sebastian Lackner from comment #15)
> I have written a patchset including tests which seems to confirm my theory:
> 
> Patches:
> https://github.com/wine-compholio/wine-staging/tree/master/patches/user32-
> FindWindowEx
> 
> Testbot:
> https://newtestbot.winehq.org/JobDetails.pl?Key=10210
> 
> Could you guys please give it a try?
> 
> Please note that patch 2 also contains some tests for GetWindowText, and
> these tests seem to confirm that everything is right with the Wine
> implementation. Applying the patch from comment 12 or
> http://source.winehq.org/patches/data/100929 breaks the tests.

Works for me, thanks Sebastina, good job!

Test with:
$ sha1sum  TDRABCSetup.exe 
fd83dfa2c0240d8dd581ce304ba0eeb96f2bf103  TDRABCSetup.exe 
(Newer version of TDRABCSetup doesn't trigger this bug)
Comment 17 Qian Hong 2014-11-18 10:28:23 CST
Fixed by http://source.winehq.org/git/wine.git/?a=commit;h=d5ba7451a34bcdd1af5734cfc320f52abc957258

Thanks Sebastian, great work :)
Comment 18 Alexandre Julliard 2014-11-28 13:58:34 CST
Closing bugs fixed in 1.7.32.
Comment 19 mrdeathjr28 2014-11-29 12:38:50 CST
confirmed arcania gothic 4 begins to work

https://www.youtube.com/watch?v=SrbCMe9Svf8

however in cinematics only works sound


Privacy Policy
If you have a privacy inquiry regarding this site, please write to privacy@winehq.org

Hosted By CodeWeavers