Open xiaozhang8tuo opened 2 years ago
(gdb) bt
at tinyrpc/coroutine/coroutine.cc:87
at /usr/include/c++/9/new:174
at /usr/include/c++/9/bits/shared_ptr_base.h:548
this=<optimized out>) at /usr/include/c++/9/bits/shared_ptr_base.h:679
at /usr/include/c++/9/bits/shared_ptr_base.h:1344
原因似乎是线程2中的t_main_coroutine没初始化
请问可以向示例这样跨线程操作同一个协程嘛
可以的,这里后面改了代码,忘记改用例了。协程是支持被不同线程调度的
(gdb) bt
0 0x000055ef99818064 in tinyrpc::Coroutine::Coroutine (this=0x55ef9b3c1b80) at /usr/include/c++/9/bits/shared_ptr_base.h:1020
1 0x000055ef99818bfd in tinyrpc::Coroutine::Coroutine(int, char*, std::function<void ()>) (this=0x55ef9b3c2180, size=, stack_ptr=, cb=...)
2 0x000055ef99816c05 in gnu_cxx::new_allocator::construct<tinyrpc::Coroutine, int&, char*&, void (&)()> ( p=0x55ef9b3c2180, this=)
3 std::allocator_traits<std::allocator >::construct<tinyrpc::Coroutine, int&, char*&, void (&)()> (p=0x55ef9b3c2180, a=...) at /usr/include/c++/9/bits/alloc_traits.h:483
4 std::_Sp_counted_ptr_inplace<tinyrpc::Coroutine, std::allocator, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<int&, char*&, void (&)()> (__a=..., this=0x55ef9b3c2170)
5 std::shared_count<(__gnu_cxx::_Lock_policy)2>::shared_count<tinyrpc::Coroutine, std::allocator, int&, char*&, void (&)()> (a=..., p=,
6 std::shared_ptr<tinyrpc::Coroutine, (__gnu_cxx::_Lock_policy)2>::shared_ptr<std::allocator, int&, char*&, void (&)()> (__tag=..., this=)
7 std::shared_ptr::shared_ptr<std::allocator, int&, char*&, void (&)()> (__tag=..., this=) at /usr/include/c++/9/bits/shared_ptr.h:359
8 std::allocate_shared<tinyrpc::Coroutine, std::allocator, int&, char*&, void (&)()> (__a=...) at /usr/include/c++/9/bits/shared_ptr.h:702
9 std::make_shared<tinyrpc::Coroutine, int&, char*&, void (&)()> () at /usr/include/c++/9/bits/shared_ptr.h:718
10 main (argc=, argv=) at testcases/test_coroutine.cc:44