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@winehq.org Reporter: mail@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 ...