chenBright commented on code in PR #3032:
URL: https://github.com/apache/brpc/pull/3032#discussion_r2217134856


##########
src/bthread/task_tracer.cpp:
##########
@@ -356,15 +356,18 @@ void TaskTracer::SignalHandler(int, siginfo_t* info, 
void* context) {
     // Ref has been taken before the signal is sent, so no need to add ref 
here.
     butil::intrusive_ptr<SignalSync> signal_sync(
         static_cast<SignalSync*>(info->si_value.sival_ptr), false);
-    if (NULL == signal_sync || NULL == signal_sync->result) {
+    if (NULL == signal_sync) {
         // The signal is not from Tracer, such as TaskControl, do nothing.
         return;
     }
-    Result* result = signal_sync->result;
+    void *pcs[Result::MAX_TRACE_NUM];
     // Skip the first frame, which is the signal handler itself.
-    result->frame_count = absl::DefaultStackUnwinder(&result->ips[0], NULL,
-                                                     arraysize(result->ips),
-                                                     1, context, NULL);
+    int depth = absl::DefaultStackUnwinder(pcs, NULL, arraysize(pcs), 1,
+                                           context, NULL);
+    signal_sync->pcs.reserve(depth);

Review Comment:
   Allocating memory in a signal handler is dangerous. Maybe we should make the 
type of result in SignalSync Result instead of Result*, just like before.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org

Reply via email to