context/test/Jamfile.v2
George Koehler 7e14ab9e45 Use mmap(2) MAP_STACK to allocate stacks on OpenBSD
Since OpenBSD 6.4 (https://www.openbsd.org/64.html), the stack pointer
must point to MAP_STACK memory, or the kernel may kill the process
with a signal.  All stack allocators must pass MAP_STACK to mmap(2).

Define BOOST_CONTEXT_USE_MAP_STACK on OpenBSD, and don't define it on
other systems.  This doesn't check for old versions of OpenBSD without
MAP_STACK; but OpenBSD has stopped maintaining versions before 6.4.

If BOOST_CONTEXT_USE_MAP_STACK is defined, then cause the stack
allocators to pass MAP_STACK to mmap(2):

 - fixedsize_stack uses mmap/munmap instead of malloc/free.  This
   comes from a patch in OpenBSD Ports.

 - protected_fixedsize_stack adds MAP_STACK to the mmap flags (as it
   does in OpenBSD Ports).  Assume that systems with MAP_STACK also
   have MAP_ANON; this is true on OpenBSD.  Delete POSIX comment,
   because I can't find MAP_ANON nor MAP_ANONYMOUS in POSIX, so these
   mmap calls don't conform to POSIX.

 - pooled_fixedsize_stack can't call munmap, because the pool's free
   doesn't know the allocation's size.  Instead use posix_memalign to
   allocate memory, then mmap to replace the pages with MAP_STACK
   pages, so the pool's free may call std::free.

OpenBSD has no <ucontext.h>, so edit test/Jamfile.v2 to skip ucontext
tests on OpenBSD.

This commit and https://github.com/boostorg/test/pull/231 causes
libs/context/test `b2 full` to pass on OpenBSD 6.5 for 64-bit x86.
`b2 fc` fails because the allocator in test_fcontext.cpp does not use
MAP_STACK.  The tests seem not to cover pooled_fixedsize_stack nor
protected_fixedsize_stack, but they still pass when I temporarily hack
callcc to use those allocators instead of fixedsize_stack.
2019-10-03 20:47:36 -04:00

219 lines
5.8 KiB
Plaintext

# Boost.Context Library Tests Jamfile
# Copyright Oliver Kowalke 2009.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
import common ;
import feature ;
import indirect ;
import modules ;
import os ;
import testing ;
import toolset ;
import ../../config/checks/config : requires ;
project boost/context/test
: requirements
<library>../../test/build//boost_unit_test_framework
<library>/boost/context//boost_context
<toolset>gcc,<segmented-stacks>on:<cxxflags>-fsplit-stack
<toolset>gcc,<segmented-stacks>on:<cxxflags>-DBOOST_USE_SEGMENTED_STACKS
<toolset>clang,<segmented-stacks>on:<cxxflags>-fsplit-stack
<toolset>clang,<segmented-stacks>on:<cxxflags>-DBOOST_USE_SEGMENTED_STACKS
<link>static
<threading>multi
<variant>release
;
rule native-impl ( properties * )
{
local result ;
if ( <target-os>android in $(properties) ||
<target-os>darwin in $(properties) ||
<target-os>openbsd in $(properties) )
{
result = <build>no ;
}
else if ( ! ( <target-os>windows in $(properties) ) )
{
result = <context-impl>ucontext ;
}
else
{
result = <context-impl>winfib ;
}
return $(result) ;
}
rule segmented-stack ( properties * )
{
local result ;
if ( <toolset>gcc in $(properties) )
{
result = <segmented-stacks>on ;
}
else
{
result = <build>no ;
}
return $(result) ;
}
test-suite minimal :
[ run test_invoke.cpp :
: :
[ requires cxx11_auto_declarations
cxx11_constexpr
cxx11_defaulted_functions
cxx11_final
cxx11_hdr_thread
cxx11_hdr_tuple
cxx11_lambdas
cxx11_noexcept
cxx11_nullptr
cxx11_rvalue_references
cxx11_template_aliases
cxx11_thread_local
cxx11_variadic_templates ] ]
[ run test_apply.cpp :
: :
[ requires cxx11_auto_declarations
cxx11_constexpr
cxx11_defaulted_functions
cxx11_final
cxx11_hdr_thread
cxx11_hdr_tuple
cxx11_lambdas
cxx11_noexcept
cxx11_nullptr
cxx11_rvalue_references
cxx11_template_aliases
cxx11_thread_local
cxx11_variadic_templates ] ]
[ run test_fiber.cpp :
: :
<context-impl>fcontext
[ requires cxx11_auto_declarations
cxx11_constexpr
cxx11_defaulted_functions
cxx11_final
cxx11_hdr_thread
cxx11_hdr_tuple
cxx11_lambdas
cxx11_noexcept
cxx11_nullptr
cxx11_rvalue_references
cxx11_template_aliases
cxx11_thread_local
cxx11_variadic_templates ]
: test_fiber_asm ]
[ run test_fiber.cpp :
: :
<conditional>@native-impl
[ requires cxx11_auto_declarations
cxx11_constexpr
cxx11_defaulted_functions
cxx11_final
cxx11_hdr_thread
cxx11_hdr_tuple
cxx11_lambdas
cxx11_noexcept
cxx11_nullptr
cxx11_rvalue_references
cxx11_template_aliases
cxx11_thread_local
cxx11_variadic_templates ]
: test_fiber_native ]
[ run test_fiber.cpp :
: :
<context-impl>ucontext
<conditional>@segmented-stack
[ requires cxx11_auto_declarations
cxx11_constexpr
cxx11_defaulted_functions
cxx11_final
cxx11_hdr_thread
cxx11_hdr_tuple
cxx11_lambdas
cxx11_noexcept
cxx11_nullptr
cxx11_rvalue_references
cxx11_template_aliases
cxx11_thread_local
cxx11_variadic_templates ]
: test_fiber_segmented ]
[ run test_callcc.cpp :
: :
<context-impl>fcontext
[ requires cxx11_auto_declarations
cxx11_constexpr
cxx11_defaulted_functions
cxx11_final
cxx11_hdr_thread
cxx11_hdr_tuple
cxx11_lambdas
cxx11_noexcept
cxx11_nullptr
cxx11_rvalue_references
cxx11_template_aliases
cxx11_thread_local
cxx11_variadic_templates ]
: test_callcc_asm ]
[ run test_callcc.cpp :
: :
<conditional>@native-impl
[ requires cxx11_auto_declarations
cxx11_constexpr
cxx11_defaulted_functions
cxx11_final
cxx11_hdr_thread
cxx11_hdr_tuple
cxx11_lambdas
cxx11_noexcept
cxx11_nullptr
cxx11_rvalue_references
cxx11_template_aliases
cxx11_thread_local
cxx11_variadic_templates ]
: test_callcc_native ]
[ run test_callcc.cpp :
: :
<context-impl>ucontext
<conditional>@segmented-stack
[ requires cxx11_auto_declarations
cxx11_constexpr
cxx11_defaulted_functions
cxx11_final
cxx11_hdr_thread
cxx11_hdr_tuple
cxx11_lambdas
cxx11_noexcept
cxx11_nullptr
cxx11_rvalue_references
cxx11_template_aliases
cxx11_thread_local
cxx11_variadic_templates ]
: test_callcc_segmented ] ;
test-suite full :
minimal ;
test-suite fc :
[ run test_fcontext.cpp :
: :
] ;
explicit minimal ;
explicit fc ;