From f12fd4b967730fa08f1a5f55f3fac6dc893fc621 Mon Sep 17 00:00:00 2001 From: anjiahao Date: Tue, 5 Mar 2024 18:33:10 +0800 Subject: [PATCH 1/3] malloc:if malloc filed need print leak memory detatls Signed-off-by: anjiahao --- mm/mm_heap/mm_malloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/mm_heap/mm_malloc.c b/mm/mm_heap/mm_malloc.c index 3d15c326ac354..7f9b455b69d64 100644 --- a/mm/mm_heap/mm_malloc.c +++ b/mm/mm_heap/mm_malloc.c @@ -378,6 +378,9 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size) # endif # ifdef CONFIG_MM_DUMP_DETAILS_ON_FAILURE mm_memdump(heap, &dump); + mwarn("Dump leak memory(thread exit, but memory not free):\n"); + dump.pid = PID_MM_LEAK; + mm_memdump(heap, &dump); # endif #endif #ifdef CONFIG_MM_PANIC_ON_FAILURE From 6eca5bf7318bddcf88f1bb9214ea2f0913c41fdf Mon Sep 17 00:00:00 2001 From: buxiasen Date: Thu, 8 Aug 2024 22:01:15 +0800 Subject: [PATCH 2/3] mm: dump more information when failed dump detail Signed-off-by: buxiasen --- mm/mm_heap/mm_malloc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mm/mm_heap/mm_malloc.c b/mm/mm_heap/mm_malloc.c index 7f9b455b69d64..c8cd761e2bdbe 100644 --- a/mm/mm_heap/mm_malloc.c +++ b/mm/mm_heap/mm_malloc.c @@ -381,6 +381,16 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size) mwarn("Dump leak memory(thread exit, but memory not free):\n"); dump.pid = PID_MM_LEAK; mm_memdump(heap, &dump); +# ifdef CONFIG_MM_HEAP_MEMPOOL + mwarn("Dump block used by mempool expand/trunk:\n"); + dump.pid = PID_MM_MEMPOOL; + mm_memdump(heap, &dump); +# endif +# if CONFIG_MM_BACKTRACE >= 0 + mwarn("Dump allocated orphan nodes. (neighbor of free nodes):\n"); + dump.pid = PID_MM_ORPHAN; + mm_memdump(heap, &dump); +# endif # endif #endif #ifdef CONFIG_MM_PANIC_ON_FAILURE From 8cc40943d81f1fa94f155d9fbe908e585241aa11 Mon Sep 17 00:00:00 2001 From: buxiasen Date: Fri, 20 Sep 2024 20:15:48 +0800 Subject: [PATCH 3/3] misc: flush syslog before possible long time cost coredump When coredump to mtd, it maybe cost lots of time, do flush syslog can make user access all log when coredump processing, should be better. Signed-off-by: buxiasen --- sched/misc/assert.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sched/misc/assert.c b/sched/misc/assert.c index c52f23df9019b..bbf9dcfaefc26 100644 --- a/sched/misc/assert.c +++ b/sched/misc/assert.c @@ -742,7 +742,12 @@ static void dump_fatal_info(FAR struct tcb_s *rtcb, #if defined(CONFIG_BOARD_COREDUMP_SYSLOG) || \ defined(CONFIG_BOARD_COREDUMP_BLKDEV) - /* Dump core information */ + + /* Flush previous SYSLOG data before possible long time coredump */ + + syslog_flush(); + + /* Dump core information */ # ifdef CONFIG_BOARD_COREDUMP_FULL coredump_dump(INVALID_PROCESS_ID);