EnterCriticalSection throws exception?

Vitaliy Margolen wine-devel at kievinfo.com
Thu Jul 3 11:51:20 CDT 2008

Huang, Zhangrong wrote:
> Hi,
> 2008/7/3 Maarten Lankhorst <m.b.lankhorst at gmail.com>:
>> Hello,
>> I think that is a bad idea, while there might be 1 or 2 real genuine
>> uses for only throwing an exception while debugging, 99% of the time
>> it's really wine deadlocking itself, it's wine's own fault and I would
>> rather see the backtraces of the deadlock rather then the app hanging
>> forever.
> OK, my thoughts:
> 1. A patch for Wine that throws exception for Wine internal locks only
> when debug is present, so after waiting for 65 seconds, some apps
> don't crash. Of course if you run app under debugger, you get
> exception to check deadlock.
> 2. Another patch to implement the missing timeout feature, Wine checks
> the timeout value NtCurrentTeb()->Peb->CriticalSectionTimeout which
> comes from registry
> HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
> Manager\CriticalSectionTimeout, then throws EXCEPTION_POSSIBLE_DEADLOCK..
> So if you want to check deadlock, setting the registry value to 30
> seconds or 60 seconds or any value you want.

Using something like this in Wine currently is ill advised. For example 
crit-sections in sound drivers will timeout when some games load next level 
on a slow hardware. However everything is functioning properly after game is 
loaded. Generating an exception will most likely cause app to crash/exit.

This can be the case for number of other resources protected with crit-sections.


More information about the wine-devel mailing list