ports/www/firefox/files/patch-bug1948776
2025-03-25 22:27:52 +01:00

50 lines
2 KiB
Text

commit 43b044fe8adaccb46868ac00c70a4e7a5d354a9c
Author: Christoph Moench-Tegeder <cmt@burggraben.net>
Bug 1948776 - handle non-existence of MAP_NORESERVE for FreeBSD, r=afranchuk,jld,nika
The MAP_NORESERVE flag does not exist in FreeBSD. As the minimally-
invasive workaround, I decided to remove that flag directly in the
mmap() calls, instead of defining our own MAP_NORESERVE as 0
possibly far away and not obviously connected to these places.
Differential Revision: https://phabricator.services.mozilla.com/D238531
diff --git ipc/glue/SharedMemoryPlatform_posix.cpp ipc/glue/SharedMemoryPlatform_posix.cpp
index 61121bcbaf8d..b31f2200e8e6 100644
--- ipc/glue/SharedMemoryPlatform_posix.cpp
+++ ipc/glue/SharedMemoryPlatform_posix.cpp
@@ -447,8 +447,12 @@ bool Platform::Protect(char* aAddr, size_t aSize, Access aAccess) {
}
void* Platform::FindFreeAddressSpace(size_t aSize) {
- void* memory = mmap(nullptr, aSize, PROT_NONE,
- MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE, -1, 0);
+#ifndef __FreeBSD__
+ constexpr int flags = MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE;
+#else
+ constexpr int flags = MAP_ANONYMOUS | MAP_PRIVATE;
+#endif
+ void* memory = mmap(nullptr, aSize, PROT_NONE, flags, -1, 0);
if (memory == MAP_FAILED) {
return nullptr;
}
diff --git ipc/glue/SharedMemory_posix.cpp ipc/glue/SharedMemory_posix.cpp
index da279f469237..9ed83af4b1f2 100644
--- ipc/glue/SharedMemory_posix.cpp
+++ ipc/glue/SharedMemory_posix.cpp
@@ -61,8 +61,12 @@ SharedMemory::Handle SharedMemory::CloneHandle(const Handle& aHandle) {
}
void* SharedMemory::FindFreeAddressSpace(size_t size) {
- void* memory = mmap(nullptr, size, PROT_NONE,
- MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE, -1, 0);
+#ifndef __FreeBSD__
+ constexpr int flags = MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE;
+#else
+ constexpr int flags = MAP_ANONYMOUS | MAP_PRIVATE;
+#endif
+ void* memory = mmap(nullptr, size, PROT_NONE, flags, -1, 0);
if (memory == MAP_FAILED) {
return nullptr;
}