$OpenBSD: patch-boost_coroutine_standard_stack_allocator_hpp,v 1.1 2019/07/18 20:27:25 sthen Exp $

Index: boost/coroutine/standard_stack_allocator.hpp
--- boost/coroutine/standard_stack_allocator.hpp.orig
+++ boost/coroutine/standard_stack_allocator.hpp
@@ -26,6 +26,8 @@
 #  include BOOST_ABI_PREFIX
 #endif
 
+#include <sys/mman.h>
+
 namespace boost {
 namespace coroutines {
 
@@ -39,8 +41,8 @@ struct basic_standard_stack_allocator
         BOOST_ASSERT( traits_type::minimum_size() <= size);
         BOOST_ASSERT( traits_type::is_unbounded() || ( traits_type::maximum_size() >= size) );
 
-        void * limit = std::malloc( size);
-        if ( ! limit) throw std::bad_alloc();
+        void * limit = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_STACK, -1, 0);
+        if ( limit == MAP_FAILED ) throw std::bad_alloc();
 
         ctx.size = size;
         ctx.sp = static_cast< char * >( limit) + ctx.size;
@@ -60,7 +62,7 @@ struct basic_standard_stack_allocator
 #endif
 
         void * limit = static_cast< char * >( ctx.sp) - ctx.size;
-        std::free( limit);
+        munmap(limit, ctx.size);
     }
 };
 
