xiaoxiang781216 commented on code in PR #21331:
URL: https://github.com/apache/nuttx/pull/21331#discussion_r4436268485


##########
mm/tlsf/mm_tlsf.c:
##########
@@ -317,13 +317,15 @@ static void memdump_backtrace(FAR struct mm_heap_s *heap,
                               FAR struct memdump_backtrace_s *buf)
 {
 #  if CONFIG_MM_BACKTRACE > 0
-  FAR struct tcb_s *tcb;
+  FAR struct tcb_s *tcb = NULL;
 #  endif
 
   buf->pid = _SCHED_GETTID();
   MM_INCSEQNO(buf);
 #  if CONFIG_MM_BACKTRACE > 0
+#    if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
   tcb = nxsched_get_tcb(buf->pid);
+#    endif
   if (heap->mm_procfs.backtrace ||
       (tcb && tcb->flags & TCB_FLAG_HEAP_DUMP))

Review Comment:
   it's better to cherry-pick this patch:
   
https://github.com/xiaoxiang781216/nuttx/commit/9bd033b486a6cce1d4930d694f8b67ab6aaddba1



##########
include/nuttx/mm/mm.h:
##########
@@ -153,9 +157,15 @@
 #  endif
 #  define MM_DUMP_ASSIGN(dump, node) \
     ((node) != NULL && (dump)->pid == (node)->pid)
-#  define MM_DUMP_LEAK(dump, node) \
+#  if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
+#    define MM_DUMP_LEAK(dump, node) \
     ((node) != NULL && (dump)->pid == PID_MM_LEAK && (node)->pid >= 0 && \
      nxsched_get_tcb((node)->pid) == NULL)
+#  else
+#    define MM_DUMP_LEAK(dump, node) \
+    ((node) != NULL && (dump)->pid == PID_MM_LEAK && (node)->pid >= 0 && \
+     kill((node)->pid, 0) != 0)

Review Comment:
   could we unify to call kill or nxsched_verify_pid



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to