This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 0132d98e419b91d38d744fd18aa920308f7ce9a9
Author: yinshengkai <[email protected]>
AuthorDate: Sat Oct 12 21:02:48 2024 +0800

    sched: delete the dump file list when the thread exits
    
    Accessing the filelist of other tasks when the thread exits may cause a 
crash
    
    Signed-off-by: yinshengkai <[email protected]>
---
 sched/sched/sched_dumponexit.c | 41 ++++++++++-------------------------------
 1 file changed, 10 insertions(+), 31 deletions(-)

diff --git a/sched/sched/sched_dumponexit.c b/sched/sched/sched_dumponexit.c
index aece6501c0..d8c6ffe256 100644
--- a/sched/sched/sched_dumponexit.c
+++ b/sched/sched/sched_dumponexit.c
@@ -26,10 +26,9 @@
 
 #include <nuttx/config.h>
 
-#include <nuttx/arch.h>
-#include <nuttx/fs/fs.h>
+#include <syslog.h>
 
-#include <debug.h>
+#include "sched/sched.h"
 
 /****************************************************************************
  * Pre-processor Definitions
@@ -41,29 +40,6 @@
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: dumphandler
- *
- * Description:
- *   Dump the state of all tasks whenever on task exits.  This is debug
- *   instrumentation that was added to check file-related reference counting
- *   but could be useful again sometime in the future.
- *
- ****************************************************************************/
-
-static void dumphandler(FAR struct tcb_s *tcb, FAR void *arg)
-{
-  FAR struct filelist *filelist;
-
-  syslog(LOG_INFO, "tcb=%p name=%s, pid:%d, priority=%d state=%d "
-         "stack_alloc_ptr: %p, adj_stack_size: %zu\n",
-         tcb, get_task_name(tcb), tcb->pid, tcb->sched_priority,
-         tcb->task_state, tcb->stack_alloc_ptr, tcb->adj_stack_size);
-
-  filelist = &tcb->group->tg_filelist;
-  files_dumplist(filelist);
-}
-
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -72,16 +48,19 @@ static void dumphandler(FAR struct tcb_s *tcb, FAR void 
*arg)
  * Name: nxsched_dumponexit
  *
  * Description:
- *   Dump the state of all tasks whenever on task exits.  This is debug
- *   instrumentation that was added to check file-related reference counting
- *   but could be useful again sometime in the future.
+ *   When the thread exits, dump the information of thread.
  *
  ****************************************************************************/
 
 void nxsched_dumponexit(void)
 {
-  sinfo("Other tasks:\n");
-  nxsched_foreach(dumphandler, NULL);
+  FAR struct tcb_s *tcb = this_task();
+  FAR const char *name = get_task_name(tcb);
+
+  syslog(LOG_INFO, "task exit! tcb=%p name=%s, tid:%d, priority=%d "
+         "entry:%p pid: %d, stack_alloc_ptr: %p, adj_stack_size: %zu\n",
+         tcb, name, tcb->pid, tcb->sched_priority, tcb->entry.main,
+         tcb->group->tg_pid, tcb->stack_base_ptr, tcb->adj_stack_size);
 }
 
 #endif /* CONFIG_SCHED_DUMP_ON_EXIT */

Reply via email to