Bug 165837 - UNO inteface cannot handle posix_fallocate EOPNOTSUPP
Summary: UNO inteface cannot handle posix_fallocate EOPNOTSUPP
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
24.2.1.2 release
Hardware: All NetBSD
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:25.8.0
Keywords:
Depends on:
Blocks:
 
Reported: 2025-03-20 14:58 UTC by Emmanuel Dreyfus
Modified: 2025-05-08 10:09 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
posix_fallocate fallback patch (2.24 KB, patch)
2025-03-20 14:58 UTC, Emmanuel Dreyfus
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Emmanuel Dreyfus 2025-03-20 14:58:09 UTC
Created attachment 199919 [details]
posix_fallocate fallback patch

The code in bridges/source/cpp_uno/shared/vtablefactory.cxx can use ftruncate() or posix_fallocate(), with a preference for the later if available.

Unfortunately, posix_fallocate() may be available while not implemented on a specific underlying filesystem. In this case, EOPNOTSUPP is returned. The current code is unable to handle that gracefuly, the error is fatal. 

Attached patch attempts to improve the situation by falling back to ftruncate() when posix_fallocate() returns EOPNOTSUPP. 

I also introduced a static flag to remember the failure, and avoid future posix_fallocate() usage if it does not work.

While there, this file has two memory allocator, one that mmap() memory RWX, and another more complicated double-mmap RW+RX scheme for systems that enforce a W^X policy. Current behavior is to always try the former allocator, then fall back to the later. I introduced a flag to remember the failure, and avoid future RWX mmap() attempts if it does not work
Comment 1 Commit Notification 2025-04-16 14:39:59 UTC
Emmanuel Dreyfus committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/9fb26786b75e30df593378954044af4e4753a192

tdf#165837 Avoid UNO failure if filesystem does not implement fallocate.

It will be available in 25.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 2 Buovjaga 2025-05-08 10:09:11 UTC
Feel free to close as fixed.