[Bug 56837] New: Bad file pointer after a file write in appending mode
https://bugs.winehq.org/show_bug.cgi?id=56837 Bug ID: 56837 Summary: Bad file pointer after a file write in appending mode Product: Wine Version: unspecified Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs(a)winehq.org Reporter: sldev(a)free.fr Distribution: Other Created attachment 76648 --> https://bugs.winehq.org/attachment.cgi?id=76648 bug-demo program and its source file When writing for append into a file, Wine returns a bad ftell() file pointer unless a fflush() is performed before querying with ftell(). See the bug-demo program (run it under bare metal Windows, then under Wine). This bug has existed like forever (Wine 6 and newer, for sure). -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56837 Fabian Maurer <dark.shadow4(a)web.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dark.shadow4(a)web.de -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56837 reserv0(a)yahoo.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |reserv0(a)yahoo.com --- Comment #1 from reserv0(a)yahoo.com --- *BUMP* Is anyone looking into this? This bug causes cache files corruptions with some applications and is pretty serious, since it breaks a very basic underlying standard C library call. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56837 Austin English <austinenglish(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version|unspecified |6.0 Keywords| |download, source -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56837 --- Comment #2 from Dmitry Timoshkov <dmitry(a)baikal.ru> --- Created attachment 78272 --> https://bugs.winehq.org/attachment.cgi?id=78272 patch This patch makes the attached test work in Wine. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56837 Dmitry Timoshkov <dmitry(a)baikal.ru> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |piotr.caban(a)gmail.com --- Comment #3 from Dmitry Timoshkov <dmitry(a)baikal.ru> --- Adding Piotr, probably he has an opinion on this. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56837 --- Comment #4 from Dmitry Timoshkov <dmitry(a)baikal.ru> --- Created attachment 78273 --> https://bugs.winehq.org/attachment.cgi?id=78273 Modified test with more traces Modified test adds traces to compare FILE and fd backend behaviour. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56837 Dmitry Timoshkov <dmitry(a)baikal.ru> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 --- Comment #5 from Dmitry Timoshkov <dmitry(a)baikal.ru> --- Confirming. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56837 Dmitry Timoshkov <dmitry(a)baikal.ru> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #78272|0 |1 is obsolete| | --- Comment #6 from Dmitry Timoshkov <dmitry(a)baikal.ru> --- Created attachment 78274 --> https://bugs.winehq.org/attachment.cgi?id=78274 patch -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56837 --- Comment #7 from sldev <sldev(a)free.fr> --- Yup, the proposed patch does fix the issue, thank you ! :-) -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56837 Piotr Caban <piotr.caban(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|-unknown |msvcrt --- Comment #8 from Piotr Caban <piotr.caban(a)gmail.com> --- I have created MR that should fix the bug: https://gitlab.winehq.org/wine/wine/-/merge_requests/7651 It's based on Dmitry's patch but moves seek to _flsbuf function. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56837 --- Comment #9 from sldev <sldev(a)free.fr> --- (In reply to Piotr Caban from comment #8)
I have created MR that should fix the bug: https://gitlab.winehq.org/wine/wine/-/merge_requests/7651
It's based on Dmitry's patch but moves seek to _flsbuf function.
Err, no, this is not a correct fix for the issue at hand. The problem was that the write happened at the start of the file instead of at the end, while the file was opened in append mode (with no lseek() call used at all: see the bug-demo sources). The suggested patch ( https://bugs.winehq.org/attachment.cgi?id=78274 ) is exactly what we need and what restores the normal behaviour of fwrite() in append mode. Instead, https://gitlab.winehq.org/wine/wine/-/merge_requests/7651 addresses only an issue with _lseek(), which won't fix our issue. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56837 --- Comment #10 from Piotr Caban <piotr.caban(a)gmail.com> --- I don't understand what's wrong, could you please describe it in more detail? I have verified that both test application output and file content is the same as on Windows. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56837 --- Comment #11 from Dmitry Timoshkov <dmitry(a)baikal.ru> --- (In reply to Piotr Caban from comment #10)
I don't understand what's wrong, could you please describe it in more detail? I have verified that both test application output and file content is the same as on Windows.
I can confirm that with the proposed MR 7651 attached test shows same result under Wine as observed under Windows. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56837 --- Comment #12 from sldev <sldev(a)free.fr> --- (In reply to Piotr Caban from comment #10)
I don't understand what's wrong, could you please describe it in more detail? I have verified that both test application output and file content is the same as on Windows.
(In reply to Dmitry Timoshkov from comment #11)
(In reply to Piotr Caban from comment #10)
I don't understand what's wrong, could you please describe it in more detail? I have verified that both test application output and file content is the same as on Windows.
I can confirm that with the proposed MR 7651 attached test shows same result under Wine as observed under Windows.
Hmm... Maybe, *if* _flsbuf() is *systematically* called during fwrite() ?... I must admit I did not look at the surrounding code and I'm not familiar with Wine at a source code level... But the first patch looked "safer" to me, since the file pointer was set just before the actual write to the file. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56837 --- Comment #13 from Piotr Caban <piotr.caban(a)gmail.com> --- The actual write to the file happens in _write function (not in fwrite). _write calls _lseek before writing to the file. So we're only trying to fix value returned by ftell/tell. The position where data is written to the file is not changed by any of these patches. It's possible to find where seek is happening. I have written some tests to confirm it should not happen in every call to fwrite. I didn't add them to the patch because I don't think it shows anything useful - I have added flsbuf() tests instead. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56837 Dmitry Timoshkov <dmitry(a)baikal.ru> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Fixed by SHA1| |a165fd43dc4c115d9e9ca0cc817 | |39045ea5f5fe5 Resolution|--- |FIXED --- Comment #14 from Dmitry Timoshkov <dmitry(a)baikal.ru> --- This should be fixed by a165fd43dc4c115d9e9ca0cc81739045ea5f5fe5. If the problem persists please feel free to reopen. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56837 --- Comment #15 from sldev <sldev(a)free.fr> --- I just made a build (of Wine 10.2, because 10.3+ makes CEF crash, and I need the latter) with a165fd43dc4c115d9e9ca0cc81739045ea5f5fe5 applied, and I can confirm that this issue is fixed for the program I was seeing it happening with (and for the bug-demo program). Thank you ! :-) -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=56837 Alexandre Julliard <julliard(a)winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED --- Comment #16 from Alexandre Julliard <julliard(a)winehq.org> --- Closing bugs fixed in 10.5. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
participants (1)
-
WineHQ Bugzilla