tinyrpc icon indicating copy to clipboard operation
tinyrpc copied to clipboard

无任何改动,执行test_coroutine产生core_dump

Open xiaozhang8tuo opened this issue 2 years ago • 3 comments

(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=...) at tinyrpc/coroutine/coroutine.cc:87 #2 0x000055ef99816c05 in __gnu_cxx::new_allocatortinyrpc::Coroutine::construct<tinyrpc::Coroutine, int&, char*&, void (&)()> (__p=0x55ef9b3c2180, this=) at /usr/include/c++/9/new:174 #3 std::allocator_traits<std::allocatortinyrpc::Coroutine >::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::allocatortinyrpc::Coroutine, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<int&, char*&, void (&)()> (__a=..., this=0x55ef9b3c2170) at /usr/include/c++/9/bits/shared_ptr_base.h:548 #5 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<tinyrpc::Coroutine, std::allocatortinyrpc::Coroutine, int&, char*&, void (&)()> (__a=..., __p=, this=) at /usr/include/c++/9/bits/shared_ptr_base.h:679 #6 std::__shared_ptr<tinyrpc::Coroutine, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocatortinyrpc::Coroutine, int&, char*&, void (&)()> (__tag=..., this=) at /usr/include/c++/9/bits/shared_ptr_base.h:1344 #7 std::shared_ptrtinyrpc::Coroutine::shared_ptr<std::allocatortinyrpc::Coroutine, int&, char*&, void (&)()> (__tag=..., this=) at /usr/include/c++/9/bits/shared_ptr.h:359 #8 std::allocate_shared<tinyrpc::Coroutine, std::allocatortinyrpc::Coroutine, 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

xiaozhang8tuo avatar Aug 16 '22 05:08 xiaozhang8tuo

原因似乎是线程2中的t_main_coroutine没初始化

xiaozhang8tuo avatar Aug 16 '22 06:08 xiaozhang8tuo

请问可以向示例这样跨线程操作同一个协程嘛

xiaozhang8tuo avatar Aug 16 '22 06:08 xiaozhang8tuo

可以的,这里后面改了代码,忘记改用例了。协程是支持被不同线程调度的

Gooddbird avatar Aug 16 '22 06:08 Gooddbird