https://bugs.winehq.org/show_bug.cgi?id=51529
Bug ID: 51529 Summary: CloseHandle(INVALID_HANDLE_VALUE) returns FALSE, GetLastError is ERROR_INVALID_HANDLE Product: Wine Version: 5.0 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: kernel32 Assignee: wine-bugs@winehq.org Reporter: sergey.bychkow@gmail.com Distribution: ---
Created attachment 70368 --> https://bugs.winehq.org/attachment.cgi?id=70368 Test CloseHandle(INVALID_HANDLE_VALUE)
CloseHandle(INVALID_HANDLE_VALUE) returns FALSE, GetLastError is ERROR_INVALID_HANDLE on Wine. I tried it with MacOSX and Linux.
But on Windows CloseHandle(INVALID_HANDLE_VALUE) returns TRUE. So many programs could fail if they didn't expect FALSE here.
Test case (Pascal). Can be compiled with FPC or Delphi.
// file TestCloseHandle.lpr
program TestCloseHandle;
{$APPTYPE CONSOLE}
uses //Winapi.Windows; Windows;
var aHandle: THandle; aResult: HRESULT; begin //aHandle := 0; aHandle := INVALID_HANDLE_VALUE;
if CloseHandle(aHandle) then aResult := 0 else aResult := GetLastError;
Writeln('Result: ', aResult); end.
https://bugs.winehq.org/show_bug.cgi?id=51529
--- Comment #1 from Nikolay Sivov bunglehead@gmail.com --- According to patches I just sent [1], [2], this behavior is only observed on Windows 10. Did you get different results?
[1] https://www.winehq.org/pipermail/wine-devel/2021-August/192343.html [2] https://www.winehq.org/pipermail/wine-devel/2021-August/192344.html
https://bugs.winehq.org/show_bug.cgi?id=51529
--- Comment #2 from Sergey Bychkow sergey.bychkow@gmail.com --- (In reply to Nikolay Sivov from comment #1)
According to patches I just sent [1], [2], this behavior is only observed on Windows 10. Did you get different results?
[1] https://www.winehq.org/pipermail/wine-devel/2021-August/192343.html [2] https://www.winehq.org/pipermail/wine-devel/2021-August/192344.html
I used to test it with Windows 10, because it's main Windows for users now. And with Wine/CrossOver, of cause.
Now I tried it with WinXP in VirtualBox, and, you are right, it returns ERROR_INVALID_HANDLE for CloseHandle(INVALID_HANDLE_VALUE), not zero (SUCCESS).
Unfortunately I have no access to all collection of Windows OSes now. But, if behaviour is so different, may be it isn't worth to change anything in Wine. There are more valuable problems to fix.
https://bugs.winehq.org/show_bug.cgi?id=51529
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|kernel32 |ntdll
--- Comment #3 from Nikolay Sivov bunglehead@gmail.com --- This is probably fixed with 1a18f3b916ef0735c5dd526251cd18a1866e2e1d. Please retest.
https://bugs.winehq.org/show_bug.cgi?id=51529
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Fixed by SHA1| |1a18f3b916ef0735c5dd526251c | |d18a1866e2e1d Status|UNCONFIRMED |RESOLVED
--- Comment #4 from Nikolay Sivov bunglehead@gmail.com --- Marking fixed, with 1a18f3b916ef0735c5dd526251cd18a1866e2e1d.
https://bugs.winehq.org/show_bug.cgi?id=51529
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #5 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 7.20.