https://bugs.winehq.org/show_bug.cgi?id=44620
Bug ID: 44620 Summary: `Nt{WaitFor,Release}KeyedEvent()` don't accept null handles, while Windows 7 does. Product: Wine Version: 3.0 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: ntdll Assignee: wine-bugs@winehq.org Reporter: lh_mouse@126.com Distribution: ---
Created attachment 60609 --> https://bugs.winehq.org/attachment.cgi?id=60609 testcase
Testcase (also attached as 'ntwaitforkeyedevent.c'):
------ #include <winternl.h> #include <winnt.h> #include <stdio.h>
__attribute__((__dllimport__, __stdcall__)) extern NTSTATUS NtWaitForKeyedEvent(HANDLE hKeyedEvent, void *pKey, BOOLEAN bAlertable, const LARGE_INTEGER *pliTimeout);
int main(void){ LARGE_INTEGER liTimeout; NTSTATUS lStatus;
liTimeout.QuadPart = -10000000; printf("Waiting...\n"); lStatus = NtWaitForKeyedEvent(NULL, &lStatus, FALSE, &liTimeout); printf("NtWaitForKeyedEvent() returned %08lx\n", lStatus);
return 0; } ------
Compiling and running this program on Linux Mint 18.3 results in the following output:
------ lh_mouse@lhmouse-ideapad-720S ~/桌面 $ x86_64-w64-mingw32-gcc ntwaitforkeyedevent.c -Wall -Wextra -Wpedantic -lntdll && ./a.exe Waiting... NtWaitForKeyedEvent() returned c0000008 lh_mouse@lhmouse-ideapad-720S ~/桌面 $ wine --version wine-3.0 lh_mouse@lhmouse-ideapad-720S ~/桌面 $ ------
On Windows 7 `NtWaitForKeyedEvent()` returns `STATUS_TIMEOUT` i.e. it succeeds:
------ E:\Desktop>x86_64-w64-mingw32-gcc ntwaitforkeyedevent.c -Wall -Wextra -Wpedantic -lntdll && a.exe Waiting... NtWaitForKeyedEvent() returned 00000102 ------
Passing null handles to `Nt{WaitFor,Release}KeyedEvent()` is how SRW locks and condition variables are implemented on Windows 7. I presume that a handle to the preallocated global keyed event with the name '\KernelObjects\CritSecOutOfMemoryEvent' is used in this case.
At the moment https://github.com/lhmouse/mcfgthread expects the Windows behavior and fails in Wine.
https://bugs.winehq.org/show_bug.cgi?id=44620
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, source, testcase
https://bugs.winehq.org/show_bug.cgi?id=44620
Gijs Vermeulen gijsvrm@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |NEW
--- Comment #1 from Gijs Vermeulen gijsvrm@gmail.com --- Confirming. Also, I added a testcase for this behaviour to the Wine test suite with: https://source.winehq.org/git/wine.git/commit/7de2754cc613a53cdf99d5ad28c9b4...
https://bugs.winehq.org/show_bug.cgi?id=44620
--- Comment #2 from Gijs Vermeulen gijsvrm@gmail.com --- Should be fixed by: a0050be13f77d364609306efb815ff8502e332ee At least your testcase prints 'NtWaitForKeyedEvent() returned 00000102' on Wine now too.
https://bugs.winehq.org/show_bug.cgi?id=44620
Liu Hao lh_mouse@126.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|NEW |RESOLVED
--- Comment #3 from Liu Hao lh_mouse@126.com --- Yes I can confirm this issue no longer exists in the following build:
``` lh_mouse@lhmouse-ideapad ~/GitHub/mcfgthread/.build_x86_64_debug $ aptitude show winehq-devel Package: winehq-devel Version: 3.19.0~bionic New: yes ```
https://bugs.winehq.org/show_bug.cgi?id=44620
Józef Kucia joseph.kucia@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |joseph.kucia@gmail.com Fixed by SHA1| |a0050be13f77d364609306efb81 | |5ff8502e332ee
https://bugs.winehq.org/show_bug.cgi?id=44620
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #4 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 3.20.