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

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

commit 3ee48b0e6421dcc103ddb49cf81e91f59a3d1ee5
Author: xuxingliang <[email protected]>
AuthorDate: Wed Nov 19 16:22:00 2025 +0800

    sim/ummheap: panic if total memory exceeds limit
    
    Limit the total memory usage.
    
    Signed-off-by: xuxingliang <[email protected]>
---
 arch/sim/src/sim/sim_ummheap.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/sim/src/sim/sim_ummheap.c b/arch/sim/src/sim/sim_ummheap.c
index 7a0addd0b19..3992355f4de 100644
--- a/arch/sim/src/sim/sim_ummheap.c
+++ b/arch/sim/src/sim/sim_ummheap.c
@@ -232,6 +232,14 @@ static void update_stats(struct mm_heap_s *heap, void 
*mem, size_t size,
             }
         }
       while (!atomic_try_cmpxchg(&heap->usmblks, &usmblks, uordblks));
+
+      if (uordblks > SIM_HEAP_SIZE)
+        {
+          merr("WARNING: Heap usage %d exceeds limit %d\n",
+                uordblks, SIM_HEAP_SIZE);
+
+          DEBUGPANIC();
+        }
     }
   else
     {

Reply via email to