Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenBSD is missing SI_ASYNCIO and SI_MESGQ #231

Closed
wants to merge 1 commit into from

Conversation

@kernigh
Copy link
Contributor

kernigh commented Oct 4, 2019

Check if macros SI_ASYNCIO and SI_MESGQ are defined as macros. This
allows to run tests on OpenBSD 6.5, where the macros are missing.

This is identical to patch-boost_test_impl_execution_monitor_ipp in
OpenBSD Ports, except that I added a comment.

@kernigh

This comment has been minimized.

Copy link
Contributor Author

kernigh commented Oct 4, 2019

This change assumes that system headers always define SI_ASYNCIO and SI_MESGQ as macros. This seems to be true in at least FreeBSD, glibc, illumos, and musl.

Check if SI_ASYNCIO and SI_MESGQ are defined as macros.  This allows
to run tests on OpenBSD 6.5, where the macros are missing.

This is identical to patch-boost_test_impl_execution_monitor_ipp in
OpenBSD Ports, except that I added a comment.
@kernigh kernigh force-pushed the kernigh:kernigh-openbsd branch from ce1d8f8 to a8b09cf Oct 4, 2019
kernigh added a commit to kernigh/context that referenced this pull request Oct 4, 2019
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 boostorg/test#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.
@raffienficiaud

This comment has been minimized.

Copy link
Member

raffienficiaud commented Oct 5, 2019

Thanks for the report, this is currently building in branch topic/PR-231-defines-missing-openbsd

@raffienficiaud raffienficiaud self-assigned this Oct 5, 2019
@raffienficiaud raffienficiaud added the 1.72 label Oct 5, 2019
@raffienficiaud raffienficiaud added this to the 1.72 milestone Oct 5, 2019
@raffienficiaud

This comment has been minimized.

Copy link
Member

raffienficiaud commented Oct 5, 2019

Merged to next.

@raffienficiaud raffienficiaud added next develop and removed next labels Oct 5, 2019
@raffienficiaud

This comment has been minimized.

Copy link
Member

raffienficiaud commented Oct 21, 2019

In master, closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.