Repository navigation
Commit eadf59e
authored
[fix](be) Fix SIGSEGV in bvar::take_sample caused by AgentCombiner/TLS Agent lifetime race under high EPS (#64040)
### What problem does this PR solve?
Issue Number: close 63193
Related PR: [#2949](apache/brpc#2949)
Problem Summary:
Under high throughput, a race condition in brpc's bvar subsystem causes
a SIGSEGV during take_sample. When a thread's TLS Agent destructs after
its owning
AgentCombiner (Reducer, IntRecorder, or Percentile) has already been
freed, the agent dereferences a dangling raw pointer in its destructor
via
combiner->commit_and_erase(this).
The fix (backport of apache/brpc#2949) replaces the raw back-pointer
from Agent to AgentCombiner with a weak_ptr, and makes the owning
classes hold the combiner via
shared_ptr. The agent destructor now calls combiner.lock() — if the
combiner is already destroyed, lock() returns null and the destructor
safely no-ops, eliminating
the use-after-free.1 parent 1533359 commit eadf59e
1 file changed
Lines changed: 439 additions & 0 deletions
0 commit comments