From: Otto Moerbeek Date: Tue, 28 Mar 2023 12:00:03 +0000 (+0200) Subject: Unbreak FreeBSD mthread stack allocation X-Git-Tag: rec-4.9.0-alpha1~26^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F12695%2Fhead;p=thirdparty%2Fpdns.git Unbreak FreeBSD mthread stack allocation On FreeBSD, MAP_STACK has a completely different meaning compared to OpenBSD. So only use MAP_STACK on OpenBSD. --- diff --git a/pdns/recursordist/lazy_allocator.hh b/pdns/recursordist/lazy_allocator.hh index 720fd4f5ee..39665b6ad2 100644 --- a/pdns/recursordist/lazy_allocator.hh +++ b/pdns/recursordist/lazy_allocator.hh @@ -28,8 +28,10 @@ #include // 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 @@ -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(); }