Skip to content

bthread_id_join->butex_wait死锁问题 #644

@hairet

Description

@hairet

Describe the bug (描述bug)
死锁堆栈如下,隐去一些我们业务方的函数,不影响观看源码,因为brpc源码我做过改动,某些行数不一定一致,但是有问题的函数是官方的,原因后面解释:
#0 0x00007f3effb436e9 in syscall () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x0000000000ba47c2 in bthread::wait_pthread(bthread::ButexPthreadWaiter&, timespec*) () at ./src/bthread/sys_futex.h:37
#2 0x0000000000ba5c7b in bthread::butex_wait(void*, int, timespec const*) () at src/bthread/butex.cpp:588
#3 0x0000000000ba76c8 in bthread_id_join () at src/bthread/id.cpp:526
#4 0x0000000000a60209 in brpc::Join(bthread_id_t) () at ./src/brpc/controller.h:396
#5 0x0000000000a84dcc in brpc::Channel::CallMethod(google::protobuf::MethodDescriptor const*, google::protobuf::RpcController*, google::protobuf::Message const*, google::protobuf::Message*, google::protobuf::Closure*, bool) ()
at src/brpc/channel.cpp:531
#6 0x0000000000a8530f in brpc::Channel::CallMethod(google::protobuf::MethodDescriptor const*, google::protobuf::RpcController*, google::protobuf::Message const*, google::protobuf::Message*, google::protobuf::Closure*) ()
at src/brpc/channel.cpp:298
#7 0x00000000008f8b7e in msg::MsgService_Stub::RpcGetMessageReq(google::protobuf::RpcController*, msg::GetMessageReq const*, msg::GetMessageRes*, google::protobuf::Closure*) ()
at MsgService.pb.cc:6388
#8 0x00000000008e46b9 in msg::SyncClient::RpcGetMessageReq(msg::GetMessageReq const*, msg::GetMessageRes*) () at MsgService.client.cc:26
#9 0x0000000000895186 in RpcGetMessageReq(protocol::message::GetMessageReq const&, protocol::message::PCS_GetMessageRes&) ()
at BrpcClientGw.cpp:42
#10 0x000000000088148e in OnGetMessageReq(protocol::message::GetMessageReq*) () at msg_query.cpp:66
#11 0x00000000009894ca in DispatchRequest(int, std::__cxx11::basic_string<char, std::char_traits, std::allocator >&, int, brpc::Controller*) ()
at handle.cpp:492
#12 0x0000000000988cf7 in LoopParseAndProcessSubHead(brpc::Controller*, std::__cxx11::basic_string<char, std::char_traits, std::allocator >) ()
at handle.cpp:411
#13 0x000000000098b9fb in ProcessFramedRequest(brpc::Controller
, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, google::protobuf::Closure) ()
at handle.h:116
#14 0x0000000000b29517 in ProcessMyRequest(brpc::InputMessageBase*) () at src/brpc/policy/my_protocol.cpp:98
#15 0x0000000000a56eb7 in brpc::ProcessInputMessage(void*) () at src/brpc/input_messenger.cpp:133
#16 0x0000000000a47a7c in bthread::TaskGroup::task_runner(long) () at src/bthread/task_group.cpp:305
#17 0x0000000000a48276 in bthread::TaskGroup::run_main_task() () at src/bthread/task_group.cpp:158
#18 0x0000000000ba23f8 in bthread::TaskControl::worker_thread(void*) () at src/bthread/task_control.cpp:73
#19 0x00007f3f00cef182 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#20 0x00007f3effb4930d in clone () from /lib/x86_64-linux-gnu/libc.so.6

To Reproduce (复现方法)
高QPS,内存高后,可能出现

Expected behavior (期望行为)
task_runner调度的标准bthread不要切到线程模式

Versions (各种版本)
OS:
Compiler:
brpc:
protobuf:

Additional context/screenshots (更多上下文/截图)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugthe code does not work as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions