]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Unbreak FreeBSD mthread stack allocation 12695/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 28 Mar 2023 12:00:03 +0000 (14:00 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 28 Mar 2023 12:00:03 +0000 (14:00 +0200)
On FreeBSD, MAP_STACK has a completely different meaning compared to
OpenBSD. So only use MAP_STACK on OpenBSD.

pdns/recursordist/lazy_allocator.hh

index 720fd4f5ee14819e8ebeb5764a4c5d132d23e362..39665b6ad266a350e3d10c5ccc5cde13fb207f1a 100644 (file)
 #include <unistd.h>
 
 // On OpenBSD mem used as stack should be marked MAP_STACK
-#if !defined(MAP_STACK)
-#define MAP_STACK 0
+#ifdef __OpenBSD__
+#define PDNS_MAP_STACK MAP_STACK
+#else
+#define PDNS_MAP_STACK 0
 #endif
 
 template <typename T>
@@ -88,7 +90,7 @@ struct lazy_allocator
 #else
     const int protection = PROT_NONE;
 #endif
-    void* p = mmap(nullptr, allocatedSize, protection, MAP_PRIVATE | MAP_ANON | MAP_STACK, -1, 0);
+    void* p = mmap(nullptr, allocatedSize, protection, MAP_PRIVATE | MAP_ANON | PDNS_MAP_STACK, -1, 0);
     if (p == MAP_FAILED) {
       throw std::bad_alloc();
     }