boost::context::basic_segmented_stack 不是按需增长

boost::context::basic_segmented_stack not growing on demand

本文关键字:stack context basic segmented boost      更新时间:2023-10-16

我有Boost 1.66,C++14,g++ 7.2.0,VM上的Ubuntu 16.04,Intel Core i5。

我正在使用 boost::fiber,就像这个例子 http://www.boost.org/doc/libs/1_65_1/libs/fiber/examples/segmented_stack.cpp 一样。

Boost::fiber relays on boost::context,我想使用 boost::context::basic_segmented_stack,如提供的示例所示。

我按照这些说明 http://www.boost.org/doc/libs/1_66_0/libs/context/doc/html/context/stack/segmented.html

。Boost.Context 必须使用属性分段堆栈构建,例如 工具集=GCC 分段堆栈=打开和应用 BOOST_USE_SEGMENTED_STACKS b2/bjam 命令行。

即第一次运行。/bootstrap.sh --with-libraries=system,program_options,fiber,context ..., then./b2 工具集=gcc segmented-stacks=on ...,并使用-DBOOST_USE_SEGMENTED_STACKS进行编译。

但是,上面的示例在迭代 321 时崩溃:

进程完成,退出代码 139(被信号 11 中断: 西格塞格夫)

使用 basic_fixedsize_stack,它在迭代 354 时崩溃。

但是有了basic_segmented_stack它不应该崩溃,因为堆栈应该按需增长,对吧?那么为什么它不增长呢?

我也用-fsplit-stack编译,但它没有区别。 当我也使用属性context-impl=ucontext运行b2并使用-BOOST_USE_UCONTEXT编译时,我得到了

CMakeFiles/BContext.dir/main.cpp.o:在函数中boost::context::continuation::~continuation()': /usr/local/include/boost/context/continuation_fcontext.hpp:229: undefined reference toontop_fcontext' CMakeFiles/BContext.dir/main.cpp.o:在函数中boost::context::continuation::resume()': /usr/local/include/boost/context/continuation_fcontext.hpp:257: undefined reference tojump_fcontext' CMakeFiles/BContext.dir/main.cpp.o:在函数'void* boost::context::d etail::create_context2 ...

b2 toolset=gcc segmented-stacks=on cxxflags="-DBOOST_USE_SEGMENTED_STACKS"

为我工作