This is an automated email from the ASF dual-hosted git repository.
guangmingchen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push:
new ac92dd37 Fix bthread task tracer deadlock bug (#2988)
ac92dd37 is described below
commit ac92dd37858f7bcfeff01fe856ed48ba6123f5ec
Author: chenyujie <[email protected]>
AuthorDate: Tue Jun 10 10:12:00 2025 +0800
Fix bthread task tracer deadlock bug (#2988)
---
src/bthread/task_tracer.cpp | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/bthread/task_tracer.cpp b/src/bthread/task_tracer.cpp
index af88ba64..1c75136c 100644
--- a/src/bthread/task_tracer.cpp
+++ b/src/bthread/task_tracer.cpp
@@ -272,6 +272,17 @@ TaskTracer::Result TaskTracer::TraceImpl(bthread_t tid) {
}
}
+ BRPC_SCOPE_EXIT {
+ {
+ BAIDU_SCOPED_LOCK(m->version_lock);
+ // If m->status is BTHREAD_STATUS_END, the bthread also waits for
+ // tracing completion, so given_version != *m->version_butex is OK.
+ m->traced = false;
+ }
+ // Wake up the waiting worker thread to jump.
+ _cond.Signal();
+ };
+
if (TASK_STATUS_UNKNOWN == status) {
return Result::MakeErrorResult("bthread=%d not exist now", tid);
} else if (TASK_STATUS_CREATED == status) {
@@ -293,15 +304,6 @@ TaskTracer::Result TaskTracer::TraceImpl(bthread_t tid) {
result = ContextTrace(m->stack->context);
}
- {
- BAIDU_SCOPED_LOCK(m->version_lock);
- // If m->status is BTHREAD_STATUS_END, the bthread also waits for
tracing completion,
- // so given_version != *m->version_butex is OK.
- m->traced = false;
- }
- // Wake up the waiting worker thread to jump.
- _cond.Signal();
-
return result;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]