Gooddbird / tinyrpc

c++ async rpc framework. 14w+qps.
Apache License 2.0
1.26k stars 189 forks source link

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

Open xiaozhang8tuo opened 2 years ago

xiaozhang8tuo commented 2 years ago

(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_allocator::construct<tinyrpc::Coroutine, int&, char*&, void (&)()> (p=0x55ef9b3c2180, this=)

at /usr/include/c++/9/new:174

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)

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::allocator, int&, char*&, void (&)()> (a=..., p=,

this=<optimized out>) 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::allocator, int&, char*&, void (&)()> (__tag=..., this=)

at /usr/include/c++/9/bits/shared_ptr_base.h:1344

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

xiaozhang8tuo commented 2 years ago

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

xiaozhang8tuo commented 2 years ago

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

Gooddbird commented 2 years ago

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