http://bugs.winehq.org/show_bug.cgi?id=7229
------- Additional Comments From yongjhen@fastmailbox.net 2007-21-01 21:04 ------- Okay.. I think I jump to my temporary conclusion too quickly.
When I launch WoW and after it shows a black screen, it stops to progress anymore and has the following errors:
err:ntdll:RtlpWaitForCriticalSection section 0x9c1c9ea0 "server.c: fd_cache_section" wait timed out in thread 0029, blocked by 0000, retrying (60 sec) err:ntdll:RtlpWaitForCriticalSection section 0x9c1c9ea0 "server.c: fd_cache_section" wait timed out in thread 0037, blocked by 0000, retrying (60 sec)
But sometimes (the probabilty is about 5~10%) it doesn't have these errors, and progress to login screen.
So I trace to the "fd_cache_section" in server.c, and find it a statical RTL_CRITICAL_SECTION. It looks like the two threads above (0029 and 0037) are blocked by some other thread, so I add some TRACE() code to critsection.c to see what happens to it, and the attached log is the result. It shows that the first thread entered the critical-section "fd_cache_section" fails to wake up the other waiting threads to me, because the race-condition on the creation of LockSemaphore as I described before.
I think it would better to create LockSemaphore when RTL_CRITICAL_SECTIONs are initialized, to avoid this problem. But in this situation, I find that "fd_cache_section" is not initialized by RtlInitializeCriticalSection() at all.
I also try to call RtlInitializeCriticalSection() on "fd_cache_section", and create a semaphore for LockSemaphore in RtlInitializeCriticalSection(), but wine terminates with the following log in this situation:
trace:ntdll:RtlInitializeCriticalSectionAndSpinCount thread 0 count=-1 owner=0 err:heap:HEAP_GetPtr Invalid heap 0x0! trace:ntdll:RtlInitializeCriticalSectionAndSpinCount NtCreateSemaphore wine client error:0: write: Bad file descriptor
I have no idea how to do this correctly, so there is no patch available.
Currently I just call get_semaphore() at the start of RtlEnterCriticalSection() to force the creation of LockSemaphore as early as possible. I hope people with more insight to wine resolve this problem, and I am willing to help if you don't have a non-Linux/MacOSX environment.