Hi Jacek,
I've been investigating the failures in the urlmon ftp protocol tests that show up on quite a few WinXP and higher machines. It seems to me that there is an inherent race condition in the test. The main thread waits in line 1822 until IInternetProtocolSink_Switch has been called. It will then call CHECK_CALLED(Switch) and SET_EXPECT(Switch). However, nothing prevents a background thread from calling IInternetProtocolSink_Switch again before SET_EXPECT(Switch) in the main thread is complete. In fact, if I add a Sleep(100) between the WaitForSingleObject() in line 1822 and the CHECK_CALLED() on the next line, the failures that show up now and then on test.winehq.org become reproducible every time. I believe the attached patch fixes the problem, it breaks the current assumption that there's a 1:1 relationship between IInternetProtocolSinc_Switch() and IInternetProtocol_Read() calls. Before shipping it off to wine-patches, I'd like your opinion, do you think this is the correct solution?
Thanks, Ge.
Ge van Geldorp wrote:
Hi Jacek,
I've been investigating the failures in the urlmon ftp protocol tests that show up on quite a few WinXP and higher machines. It seems to me that there is an inherent race condition in the test. The main thread waits in line 1822 until IInternetProtocolSink_Switch has been called. It will then call CHECK_CALLED(Switch) and SET_EXPECT(Switch). However, nothing prevents a background thread from calling IInternetProtocolSink_Switch again before SET_EXPECT(Switch) in the main thread is complete. In fact, if I add a Sleep(100) between the WaitForSingleObject() in line 1822 and the CHECK_CALLED() on the next line, the failures that show up now and then on test.winehq.org become reproducible every time. I believe the attached patch fixes the problem, it breaks the current assumption that there's a 1:1 relationship between IInternetProtocolSinc_Switch() and IInternetProtocol_Read() calls. Before shipping it off to wine-patches, I'd like your opinion, do you think this is the correct solution?
Great investigation, thanks. I wonder why it doesn't happen for http tests, in which have the same assumption. Your fix looks good for me, please send it to wine-patches.
Thanks, Jacek