get_display_dc() may be locking display_dc_section at the end of user driver initialization in LoadCursorA() called from register_builtin_classes(). If the driver initialization initiated in CreateDCW() goes in parallel with the initialization started elsewhere without holding display_dc_section, the process can deadlock.
Fixes random lockup on start in Hammerting.
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/user32/sysparams.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index 1381f387e03..a620116053a 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -548,7 +548,18 @@ static BOOL init_entry_string( struct sysparam_entry *entry, const WCHAR *str ) HDC get_display_dc(void) { EnterCriticalSection( &display_dc_section ); - if (!display_dc) display_dc = CreateDCW( L"DISPLAY", NULL, NULL, NULL ); + if (!display_dc) + { + HDC dc; + + LeaveCriticalSection( &display_dc_section ); + dc = CreateDCW( L"DISPLAY", NULL, NULL, NULL ); + EnterCriticalSection( &display_dc_section ); + if (display_dc) + DeleteDC(dc); + else + display_dc = dc; + } return display_dc; }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=81936
Your paranoid android.
=== debiant (32 bit report) ===
user32: monitor: Timeout
=== debiant (32 bit Chinese:China report) ===
user32: monitor: Timeout
=== debiant (32 bit WoW report) ===
user32: monitor: Timeout
=== debiant (64 bit WoW report) ===
user32: monitor: Timeout