菜鸟教程小白 发表于 2022-12-12 16:07:47

c++ - Boost.Coroutine 在 iPhone 上崩溃


                                            <p><p>有人尝试在 iOS 应用程序中使用 Boost.Coroutine 库吗?
如果是,是否有效?</p>

<p>我现在正在尝试这样做,但是当尝试展开堆栈应用程序的不完整协程以未捕获的异常forced_unwind() 终止时。</p>

<p>我已经在其他平台(i386(ios 模拟器)和 elf armv7(htc one x,one v))上运行了这个库,并且运行良好。但是 iOS .. :[</p>

<p>附加信息:</p>

<p>我正在尝试从 boost/coroutine/example 运行 unwind.cpp 示例:
<a href="https://github.com/olk/boost-coroutine/blob/master/example/cpp03/unwind.cpp" rel="noreferrer noopener nofollow">https://github.com/olk/boost-coroutine/blob/master/example/cpp03/unwind.cpp</a> </p>

<p>堆栈是:</p>

<pre><code>libc++abi.dylib: terminating with uncaught exception of type yboost::coroutines::detail::forced_unwind
(lldb) bt
* thread #1: tid = 0x258dd, 0x399eb1fc libsystem_kernel.dylib`__pthread_kill + 8, queue = &#39;com.apple.main-thread, stop reason = signal SIGABRT
    frame #0: 0x399eb1fc libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x39a52a52 libsystem_pthread.dylib`pthread_kill + 58
    frame #2: 0x3999c02c libsystem_c.dylib`abort + 76
    frame #3: 0x38dea98e libc++abi.dylib`abort_message + 74
    frame #4: 0x38e036e6 libc++abi.dylib`default_terminate_handler() + 254
    frame #5: 0x3943b95c libobjc.A.dylib`_objc_terminate() + 228
    frame #6: 0x38e011b2 libc++abi.dylib`std::__terminate(void (*)()) + 78
    frame #7: 0x38e012b0 libc++abi.dylib`std::terminate() + 156
    frame #8: 0x000ab2fc CoroutinesTest`__clang_call_terminate + 16
    frame #9: 0x000aefaa CoroutinesTest`yboost::coroutines::detail::pull_coroutine_object&lt;void, void (this=0x15645b90)(yboost::coroutines::push_coroutine&lt;void&gt;&amp;), yboost::coroutines::detail::standard_stack_allocator, std::__1::allocator&lt;yboost::coroutines::pull_coroutine&lt;void&gt; &gt;, yboost::coroutines::push_coroutine&lt;void&gt; &gt;::unwind_stack_() + 358 at pull_coroutine_object.hpp:804
    frame #10: 0x000aee02 CoroutinesTest`yboost::coroutines::detail::pull_coroutine_object&lt;void, void (this=0x15645b90)(yboost::coroutines::push_coroutine&lt;void&gt;&amp;), yboost::coroutines::detail::standard_stack_allocator, std::__1::allocator&lt;yboost::coroutines::pull_coroutine&lt;void&gt; &gt;, yboost::coroutines::push_coroutine&lt;void&gt; &gt;::~pull_coroutine_object() + 62 at pull_coroutine_object.hpp:862
    frame #11: 0x000aed9e CoroutinesTest`yboost::coroutines::detail::pull_coroutine_object&lt;void, void (this=0x15645b90)(yboost::coroutines::push_coroutine&lt;void&gt;&amp;), yboost::coroutines::detail::standard_stack_allocator, std::__1::allocator&lt;yboost::coroutines::pull_coroutine&lt;void&gt; &gt;, yboost::coroutines::push_coroutine&lt;void&gt; &gt;::~pull_coroutine_object() + 14 at pull_coroutine_object.hpp:860
    frame #12: 0x000aefea CoroutinesTest`yboost::coroutines::detail::pull_coroutine_object&lt;void, void (&amp;)(yboost::coroutines::push_coroutine&lt;void&gt;&amp;), yboost::coroutines::detail::standard_stack_allocator, std::__1::allocator&lt;yboost::coroutines::pull_coroutine&lt;void&gt; &gt;, yboost::coroutines::push_coroutine&lt;void&gt; &gt;::destroy_(std::__1::allocator&lt;yboost::coroutines::detail::pull_coroutine_object&lt;void, void (&amp;)(yboost::coroutines::push_coroutine&lt;void&gt;&amp;), yboost::coroutines::detail::standard_stack_allocator, std::__1::allocator&lt;yboost::coroutines::pull_coroutine&lt;void&gt; &gt;, yboost::coroutines::push_coroutine&lt;void&gt; &gt; &gt;&amp;, yboost::coroutines::detail::pull_coroutine_object&lt;void, void (&amp;)(yboost::coroutines::push_coroutine&lt;void&gt;&amp;), yboost::coroutines::detail::standard_stack_allocator, std::__1::allocator&lt;yboost::coroutines::pull_coroutine&lt;void&gt; &gt;, yboost::coroutines::push_coroutine&lt;void&gt; &gt;*) std::__1::allocator&lt;yboost::coroutines::detail::pull_coroutine_object&lt;void, void (this=0x15645cbc, __p=0x15645b90)(yboost::coroutines::push_coroutine&lt;void&gt;&amp;), yboost::coroutines::detail::standard_stack_allocator, std::__1::allocator&lt;yboost::coroutines::pull_coroutine&lt;void&gt; &gt;, yboost::coroutines::push_coroutine&lt;void&gt; &gt; &gt;::destroy(yboost::coroutines::detail::pull_coroutine_object&lt;void, void (&amp;)(yboost::coroutines::push_coroutine&lt;void&gt;&amp;), yboost::coroutines::detail::standard_stack_allocator, std::__1::allocator&lt;yboost::coroutines::pull_coroutine&lt;void&gt; &gt;, yboost::coroutines::push_coroutine&lt;void&gt; &gt;*) + 34 at memory:1739
    frame #13: 0x000aefe0 CoroutinesTest`yboost::coroutines::detail::pull_coroutine_object&lt;void, void (alloc=0x15645cbc, p=0x15645b90)(yboost::coroutines::push_coroutine&lt;void&gt;&amp;), yboost::coroutines::detail::standard_stack_allocator, std::__1::allocator&lt;yboost::coroutines::pull_coroutine&lt;void&gt; &gt;, yboost::coroutines::push_coroutine&lt;void&gt; &gt;::destroy_(std::__1::allocator&lt;yboost::coroutines::detail::pull_coroutine_object&lt;void, void (&amp;)(yboost::coroutines::push_coroutine&lt;void&gt;&amp;), yboost::coroutines::detail::standard_stack_allocator, std::__1::allocator&lt;yboost::coroutines::pull_coroutine&lt;void&gt; &gt;, yboost::coroutines::push_coroutine&lt;void&gt; &gt; &gt;&amp;, yboost::coroutines::detail::pull_coroutine_object&lt;void, void (&amp;)(yboost::coroutines::push_coroutine&lt;void&gt;&amp;), yboost::coroutines::detail::standard_stack_allocator, std::__1::allocator&lt;yboost::coroutines::pull_coroutine&lt;void&gt; &gt;, yboost::coroutines::push_coroutine&lt;void&gt; &gt;*) + 24 at pull_coroutine_object.hpp:783
    frame #14: 0x000aed8c CoroutinesTest`yboost::coroutines::detail::pull_coroutine_object&lt;void, void (this=0x15645b90)(yboost::coroutines::push_coroutine&lt;void&gt;&amp;), yboost::coroutines::detail::standard_stack_allocator, std::__1::allocator&lt;yboost::coroutines::pull_coroutine&lt;void&gt; &gt;, yboost::coroutines::push_coroutine&lt;void&gt; &gt;::deallocate_object() + 24 at pull_coroutine_object.hpp:892
    frame #15: 0x000ad9a4 CoroutinesTest`yboost::coroutines::detail::intrusive_ptr_release(p=0x15645b90) + 116 at pull_coroutine_base.hpp:311
    frame #16: 0x000ad92a CoroutinesTest`yboost::intrusive_ptr&lt;yboost::coroutines::detail::pull_coroutine_base&lt;void&gt; &gt;::~intrusive_ptr(this=0x27d5d990) + 34 at intrusive_ptr.hpp:97
    frame #17: 0x000ad902 CoroutinesTest`yboost::intrusive_ptr&lt;yboost::coroutines::detail::pull_coroutine_base&lt;void&gt; &gt;::~intrusive_ptr(this=0x27d5d990) + 14 at intrusive_ptr.hpp:96
    frame #18: 0x000ad8e8 CoroutinesTest`yboost::coroutines::pull_coroutine&lt;void&gt;::~pull_coroutine(this=0x27d5d990) + 16 at coroutine.hpp:1784
    frame #19: 0x000ad8d2 CoroutinesTest`yboost::coroutines::pull_coroutine&lt;void&gt;::~pull_coroutine(this=0x27d5d990) + 14 at coroutine.hpp:1784
    frame #20: 0x000aa0a0 CoroutinesTest`(anonymous namespace)::runnable() + 260 at CoroRunner.cpp:38
    frame #21: 0x000a9f98 CoroutinesTest`CoroRunner::run(this=0x15641dd0) + 12 at CoroRunner.cpp:84
    frame #22: 0x000c723e CoroutinesTest`-(self=0x1563f900, _cmd=0x31edde22) + 34 at Runner.mm:32
    frame #23: 0x000c65ba CoroutinesTest`-(self=0x15539dc0, _cmd=0x31eae996, application=0x15532840, launchOptions=0x00000000) + 666 at TPCAppDelegate.m:21
    frame #24: 0x31937424 UIKit`- + 276
    frame #25: 0x31936e6a UIKit`- + 1390
    frame #26: 0x319314b8 UIKit`- + 720
    frame #27: 0x318cbbe6 UIKit`- + 3142
    frame #28: 0x318caedc UIKit`- + 72
    frame #29: 0x31930ca0 UIKit`_UIApplicationHandleEvent + 664
    frame #30: 0x33dac76c GraphicsServices`_PurpleEventCallback + 608
    frame #31: 0x33dac356 GraphicsServices`PurpleEventCallback + 34
    frame #32: 0x2f10b77e CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34
    frame #33: 0x2f10b71a CoreFoundation`__CFRunLoopDoSource1 + 346
    frame #34: 0x2f109ee6 CoreFoundation`__CFRunLoopRun + 1406
    frame #35: 0x2f074540 CoreFoundation`CFRunLoopRunSpecific + 524
    frame #36: 0x2f074322 CoreFoundation`CFRunLoopRunInMode + 106
    frame #37: 0x3192ff42 UIKit`- + 762
    frame #38: 0x3192b1e4 UIKit`UIApplicationMain + 1136
    frame #39: 0x000c67c4 CoroutinesTest`main(argc=1, argv=0x27d5fcf4) + 116 at main.m:16
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>ARM 上的 IOS 使用不同于 AAPCS(这是标准)的 ABI。
boost.coroutine 在内部使用 boost.context 进行上下文切换/跳转。
直到 boost-1.55,bost.context 不支持 IOS 的 ABI。</p></p>
                                   
                                                <p style="font-size: 20px;">关于c&#43;&#43; - Boost.Coroutine 在 iPhone 上崩溃,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/19726132/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/19726132/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: c&#43;&#43; - Boost.Coroutine 在 iPhone 上崩溃