https://bugs.winehq.org/show_bug.cgi?id=43902
Bug ID: 43902 Summary: close() on a closed fd should set errno to EBADF Product: Wine Version: 2.0.2 Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: msvcrt Assignee: wine-bugs@winehq.org Reporter: olly@survex.com Distribution: ---
Created attachment 59529 --> https://bugs.winehq.org/attachment.cgi?id=59529 Fix and regression test
Calling close() on an already closed fd should set errno to EBADF - currently it doesn't set errno at all, which I discovered because it causes Xapian's test suite to fail when run under wine (one testcase calls close(fd) and checks for EBADF as a way to confirm that fd has indeed already been closed).
I've attached a patch with a fix and a regression testcase. It's against 2.0.2, but inspecting the latest code shows the bug to still be present.
https://bugs.winehq.org/show_bug.cgi?id=43902
Gijs Vermeulen gijsvrm@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |gijsvrm@gmail.com
--- Comment #1 from Gijs Vermeulen gijsvrm@gmail.com --- (In reply to Olly Betts from comment #0)
snip
Was this fixed by: https://source.winehq.org/git/wine.git/commit/677301a29cffa9474fcad4c2846611... ?
https://bugs.winehq.org/show_bug.cgi?id=43902
--- Comment #2 from Olly Betts olly@survex.com --- (In reply to Gijs Vermeulen from comment #1)
Was this fixed by: https://source.winehq.org/git/wine.git/commit/ 677301a29cffa9474fcad4c284661171092510d5 ?
No - that doesn't affect the "(!(info->wxflag & WX_OPEN))" case, which still sets "ret = -1" without setting errno to EBADF.
https://bugs.winehq.org/show_bug.cgi?id=43902
Piotr Caban piotr.caban@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED CC| |piotr.caban@gmail.com Resolution|--- |FIXED Fixed by SHA1| |67926ec8c344db4250f1e74a594 | |3d0b8a536e950
--- Comment #3 from Piotr Caban piotr.caban@gmail.com --- It's fixed by following commit (it's a modified version of your patch): 67926ec8c344db4250f1e74a5943d0b8a536e950 (msvcrt: Set errno when close() is called on already closed fd)
https://bugs.winehq.org/show_bug.cgi?id=43902
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.0-rc1.