gpt4 book ai didi

c++ - boost::context::basic_segmented_stack 不按需增长

转载 作者:太空宇宙 更新时间:2023-11-04 12:50:35 25 4
gpt4 key购买 nike

我有 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 在 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 must be built with property segmented-stacks, e.g. toolset=gcc segmented-stacks=on and applying BOOST_USE_SEGMENTED_STACKS at b2/bjam command line.

即首先运行 ./bootstrap.sh --with-libraries=system,program_options,fiber,context ...,然后./b2 toolset=gcc segmented-stacks=on ...,并使用 -DBOOST_USE_SEGMENTED_STACKS 进行编译。

但是,上面的例子在第 321 次迭代时崩溃了:

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

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

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

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

CMakeFiles/BContext.dir/main.cpp.o: In function boost::context::continuation::~continuation()':
/usr/local/include/boost/context/continuation_fcontext.hpp:229:
undefined reference to
ontop_fcontext' CMakeFiles/BContext.dir/main.cpp.o: In function boost::context::continuation::resume()':
/usr/local/include/boost/context/continuation_fcontext.hpp:257:
undefined reference to
jump_fcontext' CMakeFiles/BContext.dir/main.cpp.o: In function `void* boost::context::detail::create_context2 ...

最佳答案

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

对我有用

关于c++ - boost::context::basic_segmented_stack 不按需增长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49302703/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com