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-apps.git

commit 2b488c2c6e48a461b77d6f3d5f9a5d6db9fd80a6
Author: guoshengyuan1 <[email protected]>
AuthorDate: Tue Jul 22 10:06:53 2025 +0800

    [app/testig/kernel]: fix memory bound check in test_nuttx_mm07()
    
    test_nuttx_mm07() sized an allocation up to the largest free chunk minus
    16 bytes.  The chunk header can take more than that, for instance with a
    node guard area or backtrace records (MM_ALLOCNODE_OVERHEAD), and then
    the allocation cannot be satisfied.  Keep 128 bytes back, and compute
    the bound once per iteration.
    
    Assisted-by: Kiro:claude-opus-5-5
    Signed-off-by: guoshengyuan1 <[email protected]>
---
 testing/testsuites/kernel/mm/cases/mm_test_007.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/testing/testsuites/kernel/mm/cases/mm_test_007.c 
b/testing/testsuites/kernel/mm/cases/mm_test_007.c
index b6291693b..6773f2d7d 100644
--- a/testing/testsuites/kernel/mm/cases/mm_test_007.c
+++ b/testing/testsuites/kernel/mm/cases/mm_test_007.c
@@ -84,10 +84,12 @@ void test_nuttx_mm07(FAR void **state)
 
   for (int k = 0; k < MEMORY_LIST_LENGTH; k++)
     {
+      int max_size;
       get_mem_info(&mem_info);
       malloc_size =
           mmtest_get_rand_size(MALLOC_MIN_SIZE, MALLOC_MAX_SIZE);
-      if (mem_info.mxordblk - 16 < 0)
+      max_size = mem_info.mxordblk - 128;
+      if (max_size < 0)
         {
           syslog(LOG_INFO,
                  "TEST END because of the mem_info.mxordblk is:%d",
@@ -95,10 +97,10 @@ void test_nuttx_mm07(FAR void **state)
           break;
         }
 
-      if (malloc_size > mem_info.mxordblk - 16)
+      if (malloc_size > max_size)
         {
-          syslog(LOG_INFO, "SET memsize to:%d", mem_info.mxordblk - 16);
-          malloc_size = mem_info.mxordblk - 16;
+          syslog(LOG_INFO, "SET memsize to:%d", max_size);
+          malloc_size = max_size;
         }
 
       if (malloc_size > 0)

Reply via email to