huojianchaoyy opened a new pull request, #22275:
URL: https://github.com/apache/nuttx/pull/22275

   *Note: Please adhere to [Contributing 
Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).*
   
   ## Summary
   
   Heap fixes from Xiaomi Vela, split out of #22206 as asked in its review.
   
   - **mm: support memdump default parameters**: `mm_memdump()` keeps its own 
copy of the request; with `CONFIG_MM_BACKTRACE_SEQNO`, seqmin = seqmax = 0 
means the whole sequence range. **mmdump: fix pid ignored in foreach** then 
keeps the pid of the request.
   - **mm/memdump: fix typos**: with `CONFIG_MM_BACKTRACE > 0` and without 
`CONFIG_MM_BACKTRACE_SEQNO`, the format of `memdump_allocnode()` lost the '%' 
of "%*p" and passed an int to "%s" (crash on sim, see Testing).
   - **group.h:add task_group_s statement**: forward declaration of `struct 
task_group_s` in `kmalloc.h`, for the group heap prototypes.
   - **mm/mm_heap: fix null pointer dereference in mm_foreach**: `mm_memdump()` 
walks the heap with `mm_foreach()`, whose check of the first node read its NULL 
predecessor when the node is corrupted.
   
   ## Impact
   
   - With `CONFIG_MM_BACKTRACE_SEQNO`, a memdump request with seqmin = seqmax = 
0 dumps all sequence numbers instead of sequence number 0 only.
   - No API or Kconfig change.
   
   ## Testing
   
   Host: Ubuntu 22.04 x86_64, GCC 13.4.0, CMake 3.23 + Ninja 1.10. Base: master 
25b649e1c08.
   
   `./tools/checkpatch.sh -c -u -m -g HEAD~5..HEAD` passes.
   
   `sim:nsh` with `CONFIG_MM_BACKTRACE=8 CONFIG_MM_BACKTRACE_SEQNO=n`, `echo 
used > /proc/memdump`:
   
   ```
   master:  PID        Size Overhead            Address Backtrace
                 0          88       88*p        <- segmentation fault
   this PR: PID        Size Overhead            Address Backtrace
                 0          88       88     0x7af5da2007e8
   ```
   
   With `CONFIG_MM_BACKTRACE_SEQNO=y` (the default) the `/proc/memdump` output 
(used, pid, leak) is the same as on master.
   
   Builds (CMake): `sim:nsh` with backtrace 8 / 0, with and without 
`MM_BACKTRACE_SEQNO`, and with the TLSF manager with and without 
`MM_BACKTRACE_SEQNO`; `/proc/memdump` runs on the backtrace 8, backtrace 0 and 
TLSF builds.
   
   Not tested: real hardware.
   


-- 
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