[Bug 46047] New: Multiple applications want Windows 8+ futex-like operations kernel32.dll.WaitOnAddress , kernel32.dll.WakeByAddress{All,Single} (VLC)
https://bugs.winehq.org/show_bug.cgi?id=46047 Bug ID: 46047 Summary: Multiple applications want Windows 8+ futex-like operations kernel32.dll.WaitOnAddress, kernel32.dll.WakeByAddress{All,Single} (VLC) Product: Wine Version: 3.18 Hardware: x86-64 OS: Linux Status: NEW Severity: normal Priority: P2 Component: kernel32 Assignee: wine-bugs(a)winehq.org Reporter: focht(a)gmx.net Distribution: --- Hello folks, to track: * https://www.winehq.org/pipermail/wine-devel/2018-October/134085.html * https://www.winehq.org/pipermail/wine-devel/2018-October/134086.html There is a series of articles on the background/inner workings of this Windows 8+ futex-like operations by Raymond Chen on Microsoft developer blog "The Old New Thing": (1) https://blogs.msdn.microsoft.com/oldnewthing/20160823-00/?p=94145 ("WaitOnAddress lets you create a synchronization object out of any data variable, even a byte") (2) https://blogs.msdn.microsoft.com/oldnewthing/20160824-00/?p=94155 ("Implementing a synchronization barrier in terms of WaitOnAddress") (3) https://blogs.msdn.microsoft.com/oldnewthing/20160825-00/?p=94165 ("Implementing a critical section in terms of WaitOnAddress") (4) https://blogs.msdn.microsoft.com/oldnewthing/20160826-00/?p=94185 ("Spurious wakes, race conditions, and bogus FIFO claims: A peek behind the curtain of WaitOnAddress") Alternative overview to the blog using Github-based WIKI: https://github.com/mity/mctrl/wiki/Old-New-Win32API (click the sections to get to blog entries) WaitOnAddress() * WaitOnAddress lets you create a synchronization object out of any data variable, even a byte * Implementing a synchronization barrier in terms of WaitOnAddress * Implementing a critical section in terms of WaitOnAddress * Extending our critical section based on WaitOnAddress to support timeouts * Comparing WaitOnAddress with futexes (futexi? futexen?) * Creating a semaphore from WaitOnAddress * Creating a semaphore with a maximum count from WaitOnAddress * Creating a manual-reset event from WaitOnAddress * Creating an automatic-reset event from WaitOnAddress Related: bug 45524 ("Add a futex-based implementation of condition variables") I found multiple applications which make use of this Windows 8+ API. Example: VLC https://github.com/videolan/vlc/blob/master/src/win32/thread.c Most of them have fallback implementations if the API is not available so it's not critical to the functionality. But it's still good to have real world tests :-) Regards -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=46047 André H. <nerv(a)dawncrow.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nerv(a)dawncrow.de --- Comment #1 from André H. <nerv(a)dawncrow.de> --- Isn't that fixed then by: https://source.winehq.org/git/wine.git/commitdiff/25acfbb40b5316a8c87989d4e6... and https://source.winehq.org/git/wine.git/commitdiff/7c430f5b3cef93ac3ce85278ad... ? -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=46047 Anastasius Focht <focht(a)gmx.net> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.winehq.org/sho | |w_bug.cgi?id=46099 --- Comment #2 from Anastasius Focht <focht(a)gmx.net> --- Hello André, the patchset had no information which apps/games ought to be made functional/fixed by this. I pulled that VLC example out of nowhere, just guessing it might be useful for validation (didn't have the time to run/investigate it to finally resolve here). It now turns out we have the first regression: * bug 46099 ("Star Citizen not loading after implementation of WaitOnAddress() in wine") Regards -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=46047 Tool <codedonewell(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |codedonewell(a)gmail.com -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=46047 --- Comment #3 from Greg Smith <codedonewell(a)gmail.com> --- I've attached a log snippet to 46099 showing the problem occurring. Luckily it all happens within a few lines. Looks like a possible race condition. In any case, a waiting thread is not awoken. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=46047 --- Comment #4 from Greg Smith <codedonewell(a)gmail.com> --- There is definitely a synchronisation issue with these functions. It is possible for another thread to change the address contents and signal inside the time that WaitOnAddress checks the address contents and when it waits for an event. It is a very small window for the problem to occur, but the Star Citizen start up seems to trigger it every time so far. However, I doubt that there have been more than a 20 or 30 attempts, so the sample size is small and it may not always encounter this condition. As far as a solution goes, I haven't yet thought of a way to do it using the NtWaitForKeyedEvent/NtReleaseKeyedEvent functions. I do not have your experience with windows programming nor wine, so there may well be a way. With a common/dedicated mutex and condition pair for the WaitOnAddress WakeByAddress* functions it would be possible. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=46047 --- Comment #5 from Greg Smith <codedonewell(a)gmail.com> --- I have updated bug 46099 with a patch that contains an ntdll/om test that highlights the issue with the current implementation. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=46047 --- Comment #6 from Greg Smith <codedonewell(a)gmail.com> --- (In reply to Greg Smith from comment #5)
I have updated bug 46099 with a patch that contains an ntdll/om test that highlights the issue with the current implementation.
This test is vulnerable to a race condition of its own, and does not pass using crosstest on win10. My apologies for the noise. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=46047 Zebediah Figura <z.figura12(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|kernel32 |kernelbase Summary|Multiple applications want |Multiple applications want |Windows 8+ futex-like |Windows 8+ futex-like |operations |operations |kernel32.dll.WaitOnAddress, |kernelbase.dll.WaitOnAddres |kernel32.dll.WakeByAddress{ |s, |All,Single} (VLC) |kernelbase.dll.WakeByAddres | |s{All,Single} (VLC) CC| |z.figura12(a)gmail.com Resolution|--- |FIXED Fixed by SHA1| |7c430f5b3cef93ac3ce85278ad9 | |253afc81cfc40 Status|NEW |RESOLVED --- Comment #7 from Zebediah Figura <z.figura12(a)gmail.com> --- Since this bug was originally created to track those patches which implemented the functions, and since the subsequent regressions already have their own bug reports, let's mark this as fixed. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=46047 Alexandre Julliard <julliard(a)winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED --- Comment #8 from Alexandre Julliard <julliard(a)winehq.org> --- Closing bugs fixed in 4.2. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=46047 Zebediah Figura <z.figura12(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|kernelbase |kernel32 -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
participants (2)
-
wine-bugs@winehq.org -
WineHQ Bugzilla