http://bugs.winehq.org/show_bug.cgi?id=14915
Summary: FlushFileBuffers() fails on disk volume, sets ERROR_INVALID_HANDLE when handle supposedly valid Product: Wine Version: 1.1.2 Platform: PC OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown AssignedTo: wine-bugs@winehq.org ReportedBy: vesselinpeev@hotmail.com
Ran under Wine, the following program receives ERROR_INVALID_HANDLE as a Windows last error when the flushing call fails.
Note that if you are testing under Windows Vista, you need to run the program with administrative privileges to be able to get the handle to the volume.
For brevity, I've omitted GetLastError() printing for failure cases except the flushing one, but, needless to say, you may want to add them for full correctness / error handling / safety, or do let me know and I'll happily add these and re-post the code.
# include <windows.h> # include <stdio.h> # include <tchar.h>
int _tmain() { LPCTSTR volName = _T("\\.\C:"); HANDLE hFile = CreateFile(volName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0); if (hFile != INVALID_HANDLE_VALUE) { _tprintf(_T("Opened volume %s\n"), volName);
SetLastError(0xdeadbeef); /* to make sure that it's really the next call that sets the last error -- advice taken from Dmitry Timoshkov's comment at http://bugs.winehq.org/show_bug.cgi?id=14855 */
if (FlushFileBuffers(hFile)) { _tprintf(_T("File buffers flushed\n")); } else { DWORD dwRet = GetLastError(); _ftprintf(stderr, _T("File buffers not flushed, GetLastError() returned %lu"), dwRet); if(dwRet == ERROR_INVALID_HANDLE) { _ftprintf(stderr, _T(" ("The handle is invalid")")); } _ftprintf(stderr, ".\n"); } } else { _ftprintf(stderr, _T("Could not open volume %s\n"), volName); return -2; } if(! CloseHandle(hFile)) { _ftprintf(stderr, _T("Could not close handle to volume %s\n"), volName); return -3; } return 0; }
http://bugs.winehq.org/show_bug.cgi?id=14915
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |testcase
http://bugs.winehq.org/show_bug.cgi?id=14915
Vitaliy Margolen vitaliy@kievinfo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |minor
--- Comment #1 from Vitaliy Margolen vitaliy@kievinfo.com 2008-08-19 15:24:54 --- What real life program needs this?
http://bugs.winehq.org/show_bug.cgi?id=14915
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |ABANDONED
--- Comment #2 from Austin English austinenglish@gmail.com 2009-02-16 02:38:29 --- Abandoned. If still an issue in current (1.1.15 or newer) wine, and you can provide the requested information, please reopen.
http://bugs.winehq.org/show_bug.cgi?id=14915
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #3 from Austin English austinenglish@gmail.com 2009-02-16 02:38:45 --- Closing.
http://bugs.winehq.org/show_bug.cgi?id=14915
--- Comment #4 from Richard W.M. Jones rjones@redhat.com 2009-11-25 05:12:57 --- Created an attachment (id=24947) --> (http://bugs.winehq.org/attachment.cgi?id=24947) winsync.c
This still happens even with a recent version of Wine (1.1.32).
The handle is correct, but FlushFileBuffers returns ERROR_INVALID_HANDLE.
http://bugs.winehq.org/show_bug.cgi?id=14915
Richard W.M. Jones rjones@redhat.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |rjones@redhat.com
http://bugs.winehq.org/show_bug.cgi?id=14915
--- Comment #5 from Richard W.M. Jones rjones@redhat.com 2009-11-25 05:15:08 --- I can't see how to reopen this bug, but it needs to be reopened.
http://bugs.winehq.org/show_bug.cgi?id=14915
Jeff Zaroyko jeffz@jeffz.name changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|CLOSED |UNCONFIRMED Resolution|ABANDONED |
--- Comment #6 from Jeff Zaroyko jeffz@jeffz.name 2009-11-25 06:19:33 --- reopening then.
http://bugs.winehq.org/show_bug.cgi?id=14915
--- Comment #7 from Austin English austinenglish@gmail.com 2010-05-26 16:03:16 --- This is your friendly reminder that there has been no bug activity for 6 months. Is this still an issue in current (1.2-rc1 or newer) wine?
http://bugs.winehq.org/show_bug.cgi?id=14915
--- Comment #8 from Richard W.M. Jones rjones@redhat.com 2010-05-26 16:08:33 --- Newest wine in Fedora is 1.1.44 so I cannot test this on 1.2 yet.
http://bugs.winehq.org/show_bug.cgi?id=14915
Bruno Jesus 00cpxxx@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |00cpxxx@gmail.com
--- Comment #9 from Bruno Jesus 00cpxxx@gmail.com 2011-09-15 18:03:28 CDT --- Still present in 1.3.28-247-g54b37b8.
http://bugs.winehq.org/show_bug.cgi?id=14915
--- Comment #10 from Bruno Jesus 00cpxxx@gmail.com 2012-12-16 14:41:20 CST --- Created attachment 42823 --> http://bugs.winehq.org/attachment.cgi?id=42823 Compiled test from comment 0.
Still in wine 1.5.19. Attaching compiled exe for easier future testing.
http://bugs.winehq.org/show_bug.cgi?id=14915
Jarkko K jarkko_korpi@hotmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |jarkko_korpi@hotmail.com
--- Comment #11 from Jarkko K jarkko_korpi@hotmail.com --- I tested with wine 1.7.17
wine flush.exe Opened volume \.\C: File buffers not flushed, GetLastError() returned 6 ("The handle is invalid").
I got the exe from comment 10 (attachment)
https://bugs.winehq.org/show_bug.cgi?id=14915
Sergey fukanchik@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |fukanchik@gmail.com
https://bugs.winehq.org/show_bug.cgi?id=14915
super_man@post.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |super_man@post.com
--- Comment #12 from super_man@post.com --- fresh wine prefix
Opened volume \.\C: File buffers flushed
sounds fixed to me
wine-1.7.49-168-g3b5107d
https://bugs.winehq.org/show_bug.cgi?id=14915
Bruno Jesus 00cpxxx@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |FIXED
--- Comment #13 from Bruno Jesus 00cpxxx@gmail.com --- Indeed the specific testcase attached to this bug is now working as expected, resolving fixed. The bug is present in 1.6, and 1.7.7 I don't have other versions to test.
https://bugs.winehq.org/show_bug.cgi?id=14915
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #14 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 1.7.51.