node退出时在~NodeImpl 析构中出core
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 4.2k
- Forks
- 923
- PR merge metrics
- No merged PRs in 30d
Description
堆栈
(gdb) bt
#0 0x00007f101947b4ab in raise () from /lib64/libpthread.so.0
#1 0x0000559813aa1cfa in handle_fatal_signal(int) ()
#2
#3 0x00007f1016bbf1f7 in raise () from /lib64/libc.so.6
#4 0x00007f1016bc08e8 in abort () from /lib64/libc.so.6
#5 0x00007f1017adc809 in butil::debug::BreakDebugger () at brpc/src/butil/debug/debugger_posix.cc:242
#6 0x00007f101cb5d547 in get_or_create_tls_agent (id=) at /usr/include/bvar/detail/agent_group.h:130
#7 get_or_create_tls_agent (this=0x7f1013471370 ) at /usr/include/bvar/detail/combiner.h:295
#8 bvar::Reducer, bvar::detail::MinusFrom >::operator<< (this=0x7f1013471360 , value=) at /usr/include/bvar/reducer.h:193
#9 0x00007f1012e4b193 in braft::NodeImpl::~NodeImpl (this=0x5598d4647800, __in_chrg=) at node.cpp:518
#10 0x00007f1012e4b470 in braft::NodeImpl::~NodeImpl (this=0x5598d4647800, __in_chrg=) at node.cpp:519
#11 0x00007f1013ea40b5 in DeleteInternal (x=0x5598d4647800) at /usr/include/butil/memory/ref_counted.h:191
#12 Destruct (x=0x5598d4647800) at /usr/include/butil/memory/ref_counted.h:152
#13 butil::RefCountedThreadSafe >::Release (this=0x5598d4647808) at /usr/include/butil/memory/ref_counted.h:180
#14 0x00007f1012e93644 in braft::OnPreVoteRPCDone::~OnPreVoteRPCDone (this=0x5598ad8bf800, __in_chrg=) at node.cpp:2917
#15 0x00007f1012e93746 in braft::OnPreVoteRPCDone::~OnPreVoteRPCDone (this=0x5598ad8bf800, __in_chrg=) at node.cpp:2918
#16 0x00007f1012e93a5c in braft::OnPreVoteRPCDone::Run (this=0x5598ad8bf800) at node.cpp:2931
#17 0x00007f1017bcb0f2 in brpc::Controller::EndRPC (this=0x5598ad8bf8a0, info=...) at brpc/src/brpc/controller.cpp:883
#18 0x00007f1017bcb2c0 in brpc::Controller::RunEndRPC (arg=) at brpc/controller.cpp:684
#19 0x00007f1017b65c75 in bthread::TaskGroup::task_runner (skip_remained=) at brpc/src/bthread/task_group.cpp:297
#20 0x00007f1017b4d061 in bthread_make_fcontext () from /lib64/libbrpc.so
(gdb) p g_num_nodes
$2 = {, bvar::detail::MinusFrom >> = { = {_vptr.Variable = 0x7f101815dc30 , _name = ""}, _combiner = {
_id = -1, _op = {}, _lock = { = {_native_handle = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = -1, __spins = 0, __elision = 0, __list = {
__prev = 0x0, __next = 0x0}}, __size = '\000' , "\377\377\377\377", '\000' , __align = 0}}, }, _global_result = -20,
_result_identity = 0, _element_identity = 0, _agents = {root_ = {previous_ = 0x7f10134713b8 , next_ = 0x7f10134713b8 }}}, _sampler = 0x0,
_series_sampler = 0x0, _inv_op = {}}, }
从gdb中的g_num_nodes打印中可以看到,g_num_nodes已经被析构了。但是该变量是静态变量,应该是等到程序退出的时候才析构。不知道这个是什么问题?不知道有没有什么思路呢?
@PFZheng
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the gdb trace at node.cpp:518, where braft::NodeImpl::~NodeImpl releases g_num_nodes, and inspect the static g_num_nodes definition and its bvar Reducer implementation in /usr/include/bvar/detail/agent_group.h and reducer.h. Reproduce shutdown with the reported stack, then determine why the reducer appears destroyed before NodeImpl and document a verified lifecycle-safe fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100