From 8997ce47bda0a667ee41e49bdb2131bdedd9ef25 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Tue, 28 Mar 2023 14:00:03 +0200 Subject: [PATCH] Unbreak FreeBSD mthread stack allocation On FreeBSD, MAP_STACK has a completely different meaning compared to OpenBSD. So only use MAP_STACK on OpenBSD. --- pdns/recursordist/lazy_allocator.hh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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(); } -- 2.47.2