apache / apache/brpc

example/rdma_performance性能测试偶发报错bad_weak_ptr,导致core dumped

Open
#3,288 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
17.6k
Forks
4.1k
Avg merge
2d 12h
Merged PRs (30d)
69

Description

**Describe the bug**
AgentCombiner类继承自enable_shared_from_this,内部会有一个weak_ptr成员,这个成员是在对象被第一个std::shared_ptr管理时才会被初始化,相当于必须要有make_shared出来的shared_ptr管理才能正常使用weak_ptr成员,所以在类似偶发的Reducer对象/IntRecorder对象/Percentile对象 销毁后或初始化前(没有shared_ptr管理weak_ptr成员)再调用该类的operator<<函数录入样本数据, operator<<函数调用_combiner->get_or_create_tls_agent(),_combiner->get_or_create_tls_agent()再调用this->shared_from_this()就会报错bad_weak_ptr
所以长时间重复执行下述命令就会偶发报错bad_weak_ptr
taskset -c 0-95 ./kpl_tools server -use_rdma 0 -thread_num 96
taskset -c 48-95 ./kpl_tools client -thread_num 48 -queue_depth 85 -attachment_size 131072 -use_rdma 0 -connection_type pooled

terminate called after throwing an instance if 'std::bad_weak_ptr'
what(): bad_weak_ptr
Aborted (core dumped)

**To Reproduce**
在两个shell窗口分别执行如下命令:
taskset -c 0-95 ./kpl_tools server -use_rdma 0 -thread_num 96

taskset -c 48-95 ./kpl_tools client -thread_num 48 -queue_depth 85 -attachment_size 131072 -use_rdma 0 -connection_type pooled

**Expected behavior**
预期长时间重复执行上述命令不会偶发报错bad_weak_ptr

**Versions**
OS: openEuler 24.03 (LTS-SP2)
Compiler: gcc 12.3.1
brpc: 1.16
protobuf: protobuf-25.1-12.oe2403sp2.aarch64

**Additional context/screenshots**

Contributor guide

Open the contributing guide

Research direction

Start by tracing AgentCombiner, Reducer, IntRecorder, and Percentile through operator<<, get_or_create_tls_agent(), and shared_from_this(). Reproduce with the two taskset commands and stress the server/client pair. Done means repeated runs no longer terminate with std::bad_weak_ptr or produce a core dump.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
networking, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.