casaroli opened a new pull request, #4079:
URL: https://github.com/apache/nuttx-apps/pull/4079

   depends-on: apache/nuttx/pull/21961
   
   ## Summary
   
   `malloc()`, `calloc()` and `realloc()` must return memory that is aligned 
for every type (C11 7.22.3), that is to `alignof(max_align_t)`. No test checks 
this today. This PR adds case 9 to the mm cmocka suite (`cmocka_mm_test`, 
`CONFIG_CM_MM_TEST`): it allocates 1024 blocks of many sizes, frees one in 
three, reallocates the others and fills the holes with `calloc()`, and counts 
the pointers that are not aligned to `alignof(max_align_t)`. The case gets the 
alignment from `offsetof()` of a `max_align_t` member, so it needs no C11 
keyword. It reads each address back through a `volatile`: GCC assumes that 
`malloc()` memory is aligned to 16 on 64-bit targets, and at -O2 it removes a 
check such as `(uintptr_t)p % 16`.
   
   Depends on apache/nuttx#21961, which makes the default heap alignment 16 on 
64-bit architectures. With the old default 8, this case fails there.
   
   ## Impact
   
   Test only. The new file is in the existing `kernel/mm/cases/` directory, 
which the Make and CMake builds take with a wildcard.
   
   ## Testing
   
   `cmocka_mm_test` with `CONFIG_CM_MM_TEST` (and cmocka: 
`ALLOW_MIT_COMPONENTS`, `LIBC_REGEX`, `ARCH_SETJMP_H`):
   
   | configuration | nuttx master | with apache/nuttx#21961 |
   |---|---|---|
   | qemu-armv8a:nsh (flat, arm64, QEMU HVF) | `test_nuttx_mm09` FAIL: 1023 
pointers not aligned; cases 1-8 PASS | 9 of 9 PASS |
   | rv-virt:nsh64 (flat, RV64, QEMU TCG) | `test_nuttx_mm09` FAIL: 997 
pointers not aligned; cases 1-8 PASS | 9 of 9 PASS |
   
   ostest passes (exit status 0) in the same qemu-armv8a:nsh images. 
tools/checkpatch.sh passes.
   


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