Segfault with ucontext on macOS (#184, continued)

Open
#238 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp

Research direction

Start with Boost.Context’s fibonacci example and reproduce the macOS segfault when standard C++ headers precede boost/context/fiber.hpp. Inspect how Boost.Context’s build exports compiler definitions, then verify that clients receive _XOPEN_SOURCE and the example no longer segfaults.

Written by the indexing model from the issue text.

Description

Although #213, accepted in #184, did apparently fix part of the problem, Boost.Context's own example programs still segfault due to the _XOPEN_SOURCE issue described in that pull request: if a Boost.Context client includes (for example) a standard C++ header before a Boost.Context one, _XOPEN_SOURCE is not defined when the ucontext struct is defined, resulting in its definition having fewer fields than when _XOPEN_SOURCE is defined, as Boost.Context expects it to be. Thus the segfault.

For example, I fixed the fibonacci example's segfault by moving #include <boost/context/fiber.hpp> above the inclusions of the stdlib headers.

Seems like the best workaround at this point is to export -D_XOPEN_SOURCE to clients from Boost.Context's build.

Dominant language
Assembly
Stars
371
Forks
185
Avg merge
4d 13h
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/context

All issues in boostorg/context

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.