[Bug 46098] New: ftruncate fails with Invalid Argument when file is memory mapped
https://bugs.winehq.org/show_bug.cgi?id=46098 Bug ID: 46098 Summary: ftruncate fails with Invalid Argument when file is memory mapped Product: Wine Version: 3.18 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs(a)winehq.org Reporter: mail(a)georg.so Distribution: --- Created attachment 62726 --> https://bugs.winehq.org/attachment.cgi?id=62726 Show how ftruncate fails when file is also memory mapped When truncating a file with ftruncate() that is still memory mapped, the ftruncate() fails with -1 and errno is set to 'Invalid argument'. Truncating the file after the unmap does work. Expected behavior: the ftruncate also succeeds when the file is still memory mapped. I can reproduce this issue under Wine Staging 3.17 and 3.18 (i.e. wine-3.18-1.fc27.x86_64) under Fedora 27. Note that truncating before the unmap used to work with older Wine versions. It also works under Linux and under native Windows. When I run the wine under strace I don't see any failing truncate syscall. I've attached a minimal reproducing example. Example output: Truncate before unmap: $ wine64 ./test_ftruncate.exe blah 2nd ftruncate before unmap: Invalid argument $ echo $? 10 $ ls -l blah ... 2342 ... Truncate the file after unmap: $ wine64 ./test_ftruncate.exe blah 1 $ echo $? 0 $ ls -l blah ... 23 ... -- 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=46098 Alexandre Julliard <julliard(a)winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|-unknown |-unknown CC| |leslie_alistair(a)hotmail.com | |, z.figura12(a)gmail.com Product|Wine |Wine-staging --- Comment #1 from Alexandre Julliard <julliard(a)winehq.org> --- This is a Wine-staging bug, it works correctly 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=46098 Alexandre Julliard <julliard(a)winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Product|Wine-staging |Wine Component|-unknown |ntdll --- Comment #2 from Alexandre Julliard <julliard(a)winehq.org> --- Actually your test case fails on Windows too, so it's Wine-staging that's more correct (though the error code seems different). -- 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=46098 --- Comment #3 from Georg Sauthoff <mail(a)georg.so> --- Interesting, I'll check the windows system I remember where it worked before, tomorrow. -- 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=46098 --- Comment #4 from Zebediah Figura <z.figura12(a)gmail.com> --- How was this compiled? As far as I can tell ftruncate() doesn't exist 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=46098 --- Comment #5 from Georg Sauthoff <mail(a)georg.so> --- I cross-compiled this with mingw (using the Fedora packages), i.e.: $ x86_64-w64-mingw32-gcc -Wall test_ftruncate.cc -o test_ftruncate.exe -- 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=46098 --- Comment #6 from Zebediah Figura <z.figura12(a)gmail.com> --- (In reply to Georg Sauthoff from comment #5)
I cross-compiled this with mingw (using the Fedora packages), i.e.:
$ x86_64-w64-mingw32-gcc -Wall test_ftruncate.cc -o test_ftruncate.exe
Ah, okay, I see mingw aliases that to _chsize(). -- 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=46098 --- Comment #7 from Georg Sauthoff <mail(a)georg.so> --- (In reply to Alexandre Julliard from comment #2)
Actually your test case fails on Windows too, so it's Wine-staging that's more correct (though the error code seems different).
So I ran this test-case again today under native-windows (windows 8 professional, 64 bit, bare-metal, test-case cross-compiled on Fedora with mingw) and it does fail with: 2nd ftruncate before unmap: Permission denied Thus, there was some human error in the execution of my previous experiment and I take my original comment back regarding the windows behavior. Since my main use case for Wine is to conveniently run cross-compiled unit-test suites (e.g. when it's simpler to integrate in a CI environment or quicker during development) I appreciate that Wine now behaves more like native 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.
participants (1)
-
wine-bugs@winehq.org