https://bugs.winehq.org/show_bug.cgi?id=57035
Bug ID: 57035 Summary: syscalls taking absolute timeouts may resume prematurely Product: Wine Version: 9.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: ---
testcase: ```c // x86_64-w64-mingw32-gcc test.c -Wall -Wextra -O2 -lntdll #include <windows.h> #include <winternl.h> #include <stdio.h>
int main(void) { LARGE_INTEGER t1, t2;
// Get current time and round up to a one-second boundary. GetSystemTimeAsFileTime((FILETIME*) &t1); t1.QuadPart /= 10000000; t1.QuadPart *= 10000000; t1.QuadPart += 20000000;
// Wait for the current process itself (effectively sleep). printf("sleep until %lld\n", t1.QuadPart); NtWaitForSingleObject((HANDLE) -1, FALSE, &t1);
// Check current time. GetSystemTimeAsFileTime((FILETIME*) &t2); printf("current time %lld\n", t2.QuadPart); } ```
On Wine 9.0 the `NtWaitForSingleObject` syscall may resume before the timeout: ``` $ wine ./a.exe sleep until 133673207280000000 current time 133673207279998808
$ wine --version wine-9.0 (Ubuntu 9.0~repack-4build3) ```
This behavior was not observed on Wine 6.0 (Ubuntu "Jammy" 22.04 LTS), and is not observed on any physical installation of Windows 10 on x86-64, nor on Windows 11 on x86-64 or ARM64.