Moving a pending task aborts with `-fno-exceptions` and libc++
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start with the task_receiver move constructor, which calls moved_from_exception() when the source is neither done nor holds an exception, and with that helper's std::make_exception_ptr call that stores error::moved_from. Build the repro with -fno-exceptions and the Cobalt sources detail/exception.cpp, error.cpp and this_thread.cpp to see the abort. Done means the move completes without aborting in no-exceptions mode, with the same observable state as the -fexceptions build. Choosing how to represent the moved-from state without an exception needs maintainer input.
Written by the indexing model from the issue text.
Description
AI disclosure: This issue was identified and investigated by OpenAI Codex, a coding agent based on the GPT-6 large language model. The reproducer was compiled and run locally by the agent, and this report is being published with the user's approval.
Description
Moving a pending boost::cobalt::task aborts when both the application and the required Cobalt sources are compiled with -fno-exceptions.
The example performs a valid ownership transfer. It does not use the moved-from object, execute the coroutine, or perform any I/O operation through Asio.
Environment
- Boost 1.92.0
- Apple Clang 21.0.0 (
clang-2100.3.34.2) - macOS, arm64
- libc++
- C++20
Minimal reproducer
Save as repro.cpp:
#include <boost/cobalt/task.hpp>
#include <boost/throw_exception.hpp>
#include <cstdio>
#include <cstdlib>
#include <exception>
#include <utility>
#ifdef BOOST_NO_EXCEPTIONS
namespace boost {
void throw_exception(std::exception const&)
{
std::fputs("Unexpected boost::throw_exception call\n", stderr);
std::abort();
}
void throw_exception(std::exception const& error,
boost::source_location const&)
{
throw_exception(error);
}
} // namespace boost
#endif
boost::cobalt::task<int> answer()
{
co_return 42;
}
int main()
{
auto first = answer();
std::fputs("Before move\n", stderr);
auto second = std::move(first);
std::fputs("After move\n", stderr);
}
The boost::throw_exception definitions satisfy Boost's no-exceptions linking requirements. Their diagnostic is not printed during reproduction.
Build and run
Set the paths to matching Boost 1.92.0 headers and Cobalt sources. For an extracted full Boost source release:
export BOOST_INCLUDE=/absolute/path/to/boost_1_92_0
export COBALT_SRC="$BOOST_INCLUDE/libs/cobalt/src"
clang++ -std=c++20 -stdlib=libc++ -O0 -g -fno-exceptions \
-DBOOST_COBALT_SOURCE=1 -DBOOST_COBALT_NO_LIB=1 \
-I"$BOOST_INCLUDE" \
repro.cpp \
"$COBALT_SRC/detail/exception.cpp" \
"$COBALT_SRC/error.cpp" \
"$COBALT_SRC/this_thread.cpp" \
-o repro-off
./repro-off
No prebuilt Boost library is linked. The consumer and Cobalt sources use the same exception setting.
Expected behavior
Successful ownership transfer, printing both messages and exiting with status zero.
Actual behavior
Compilation and linking succeed. Execution prints:
Before move
make_exception_ptr was called in -fno-exceptions mode
The process terminates with SIGABRT.
As a control, replacing -fno-exceptions with -fexceptions in the same command produces:
Before move
After move
The control exits with status zero.
Investigation
The task_receiver move constructor calls moved_from_exception() when !done && !exception. That helper calls std::make_exception_ptr to store error::moved_from in the source object. libc++ aborts in this function when compiled without exceptions.
This appears to be a gap in the support introduced by #160, related to #18. Could this valid move avoid constructing an exception when exception handling is disabled?
The runtime failure above was reproduced on the stated native configuration; it has not been verified across other standard libraries or WebAssembly.
- Dominant language
- C++
- Stars
- 351
- Forks
- 47
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/cobalt
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 5/5 Over a week Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
sav-oss-org/ptusa_main#1610 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
open-astro/AlpacaBridge#2606 · 1 comment ·
Maintainers usually reply within 1 day
-
Refactor force_torque_system integration test to use EcmScopePossibly taken @patelshivani2283-lab claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Niko1221/Strata#6731 · 2 comments ·
Maintainers usually reply within 6 days
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 85/100