-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FreeBSD compatibility... #110
Comments
The linux (ubuntu 24.04)
the FreeBSD14
So these are very similar. However, they both seem to suggest that if you want read/write access then you need to "or together" the It seems that FreeBSD actually stricly requires so I tried changing the relevant --- ext/mio/include/mio/detail/mmap.ipp.orig 2024-12-08 17:27:01.903206000 +0000
+++ ext/mio/include/mio/detail/mmap.ipp 2024-12-08 17:27:07.038059000 +0000
@@ -205,7 +205,7 @@
char* mapping_start = static_cast<char*>(::mmap(
0, // Don't give hint as to where to map.
length_to_map,
- mode == access_mode::read ? PROT_READ : PROT_READ,
+ mode == access_mode::read ? PROT_READ : PROT_READ | PROT_WRITE,
MAP_SHARED,
file_handle,
aligned_offset));
This fixes the issue for me on FreeBSD and still works fine on Linux. Windows is not affected as it is in the other I think this change would make the mio library more faithfully adhere to its documented intent: /**
* This is the basis for all read-write mmap objects and should be preferred over
* directly using `basic_mmap`.
*/
template<typename ByteT>
using basic_mmap_sink = basic_mmap<access_mode::write, ByteT>; on a wider range of POSIX platforms, including FreeBSD. |
see also: vimpunk/mio#110
Is FreeBSD supported?
The following code snippet leads to a segfault on FreeBSD 14, but works fine on Linux (Ubuntu 24.04 or on Windows/mingw) :
I am using mio::access_mode::write because in the original code it is writing and and then reading. If I change it to
mmap_source
it works fine.I definitely have read and write permissions to the file, and an earlier instance of mmap_sink could write to the file.
I single stepped through the code, and is correctly opening the file with
O_RDWR
and passingPROT_WRITE
to the::mmap
call.If I change
mmap.ipp:L208
to always passPROT_READ
, it works fine.The text was updated successfully, but these errors were encountered: