You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "pkarashchenko (via GitHub)" <gi...@apache.org> on 2023/05/29 10:58:03 UTC
[GitHub] [nuttx] pkarashchenko commented on a diff in pull request #9417: mm: add invalid pid dump when malloc failed
pkarashchenko commented on code in PR #9417:
URL: https://github.com/apache/nuttx/pull/9417#discussion_r1209194007
##########
mm/mempool/mempool.c:
##########
@@ -436,12 +437,15 @@ mempool_info_task(FAR struct mempool_s *pool,
list_for_every_entry(&pool->alist, buf, struct mempool_backtrace_s,
node)
{
- if (buf->pid == dump->pid &&
- buf->seqno >= dump->seqmin &&
- buf->seqno <= dump->seqmax)
+ if (buf->pid == dump->pid ||
+ (dump->pid == MM_BACKTRACE_INVALID_PID &&
+ !nxsched_get_tcb(buf->pid)))
Review Comment:
```suggestion
nxsched_get_tcb(buf->pid) == NULL))
```
##########
mm/mm_heap/mm_mallinfo.c:
##########
@@ -98,16 +98,24 @@ static void mallinfo_task_handler(FAR struct mm_allocnode_s *node,
DEBUGASSERT(nodesize >= SIZEOF_MM_ALLOCNODE);
#if CONFIG_MM_BACKTRACE < 0
if (handle->dump->pid == MM_BACKTRACE_ALLOC_PID)
-#else
- if ((handle->dump->pid == MM_BACKTRACE_ALLOC_PID ||
- handle->dump->pid == node->pid) &&
- node->seqno >= handle->dump->seqmin &&
- node->seqno <= handle->dump->seqmax)
-#endif
{
handle->info->aordblks++;
handle->info->uordblks += nodesize;
}
+#else
+ if (handle->dump->pid == MM_BACKTRACE_ALLOC_PID ||
+ handle->dump->pid == node->pid ||
+ (handle->dump->pid == MM_BACKTRACE_INVALID_PID &&
+ !nxsched_get_tcb(node->pid)))
Review Comment:
```suggestion
nxsched_get_tcb(node->pid) == NULL))
```
##########
mm/mm_heap/mm_malloc.c:
##########
@@ -81,12 +81,12 @@ void mm_dump_handler(FAR struct tcb_s *tcb, FAR void *arg)
struct mallinfo_task info;
struct mm_memdump_s dump;
- dump.pid = tcb->pid;
+ dump.pid = tcb ? tcb->pid : MM_BACKTRACE_INVALID_PID;
dump.seqmin = 0;
dump.seqmax = ULONG_MAX;
info = mm_mallinfo_task(arg, &dump);
mwarn("pid:%5d, used:%10d, nused:%10d\n",
- tcb->pid, info.uordblks, info.aordblks);
+ tcb ? tcb->pid : -1, info.uordblks, info.aordblks);
Review Comment:
```suggestion
dump.pid, info.uordblks, info.aordblks);
```
##########
mm/mm_heap/mm_mallinfo.c:
##########
@@ -98,16 +98,24 @@ static void mallinfo_task_handler(FAR struct mm_allocnode_s *node,
DEBUGASSERT(nodesize >= SIZEOF_MM_ALLOCNODE);
#if CONFIG_MM_BACKTRACE < 0
if (handle->dump->pid == MM_BACKTRACE_ALLOC_PID)
-#else
- if ((handle->dump->pid == MM_BACKTRACE_ALLOC_PID ||
- handle->dump->pid == node->pid) &&
- node->seqno >= handle->dump->seqmin &&
- node->seqno <= handle->dump->seqmax)
-#endif
{
handle->info->aordblks++;
handle->info->uordblks += nodesize;
}
+#else
+ if (handle->dump->pid == MM_BACKTRACE_ALLOC_PID ||
+ handle->dump->pid == node->pid ||
+ (handle->dump->pid == MM_BACKTRACE_INVALID_PID &&
+ !nxsched_get_tcb(node->pid)))
+ {
+ if (node->seqno >= handle->dump->seqmin &&
+ node->seqno <= handle->dump->seqmax)
Review Comment:
```suggestion
if (node->seqno >= handle->dump->seqmin &&
node->seqno <= handle->dump->seqmax)
```
##########
mm/tlsf/mm_tlsf.c:
##########
@@ -294,16 +294,24 @@ static void mallinfo_task_handler(FAR void *ptr, size_t size, int used,
{
#if CONFIG_MM_BACKTRACE < 0
if (handler->dump->pid = MM_BACKTRACE_ALLOC_PID)
-#else
- if ((handler->dump->pid == MM_BACKTRACE_ALLOC_PID ||
- handler->dump->pid == dump->pid) &&
- dump->seqno >= handler->dump->seqmin &&
- dump->seqno <= handler->dump->seqmax)
-#endif
{
handler->info->aordblks++;
handler->info->uordblks += size;
}
+#else
+ if (handler->dump->pid == MM_BACKTRACE_ALLOC_PID ||
+ handler->dump->pid == dump->pid ||
+ (handler->dump->pid == MM_BACKTRACE_INVALID_PID &&
+ !nxsched_get_tcb(dump->pid)))
Review Comment:
```suggestion
nxsched_get_tcb(dump->pid) == NULL))
```
##########
mm/tlsf/mm_tlsf.c:
##########
@@ -294,16 +294,24 @@ static void mallinfo_task_handler(FAR void *ptr, size_t size, int used,
{
#if CONFIG_MM_BACKTRACE < 0
if (handler->dump->pid = MM_BACKTRACE_ALLOC_PID)
-#else
- if ((handler->dump->pid == MM_BACKTRACE_ALLOC_PID ||
- handler->dump->pid == dump->pid) &&
- dump->seqno >= handler->dump->seqmin &&
- dump->seqno <= handler->dump->seqmax)
-#endif
{
handler->info->aordblks++;
handler->info->uordblks += size;
}
+#else
+ if (handler->dump->pid == MM_BACKTRACE_ALLOC_PID ||
+ handler->dump->pid == dump->pid ||
+ (handler->dump->pid == MM_BACKTRACE_INVALID_PID &&
+ !nxsched_get_tcb(dump->pid)))
+ {
+ if (dump->seqno >= handler->dump->seqmin &&
+ dump->seqno <= handler->dump->seqmax)
Review Comment:
```suggestion
if (dump->seqno >= handler->dump->seqmin &&
dump->seqno <= handler->dump->seqmax)
```
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org