Fix-Point opened a new pull request, #21764:
URL: https://github.com/apache/nuttx/pull/21764

   ## Summary
   
   This PR fixes assert-expression stringification so macro-heavy assert 
conditions no longer bloat `.rodata`. `DEBUGASSERT()` expanded its argument 
before stringification (the `DEBUGASSERT(f) -> _ASSERT(f) -> #f` chain 
macro-replaces `f` at the first boundary), so `#f` captured the expanded token 
sequence; with `__INT128_DEFINED`, `FLS()` expands to both `FLS64()` and 
`FLS128()` (a full ternary tree each), and a single `DEBUGASSERT(nodesize >= 
MM_MIN_CHUNK)` in `mm/mm_heap/mm.h` reached 67,165 bytes — the +49 KB `.rodata` 
reported on qemu-intel64 with `CONFIG_DEBUG_ASSERTIONS_EXPRESSION`.
   
   The fix stringifies at the first macro level: 
`_ASSERT_STR()`/`_VERIFY_STR()` take the expression string as a parameter, and 
`DEBUGASSERT()`/`DEBUGVERIFY()`/`ASSERT()`/`VERIFY()`/`assert()` pass `#f` 
themselves. The 3-argument `_ASSERT()`/`_VERIFY()` are kept for compatibility 
(their direct callers still capture the literal argument text).
   
   ## Impact
   
   - User: none — the assertion condition is evaluated exactly as before; only 
the diagnostic string changes (it now shows the source text, e.g. `nodesize >= 
MM_MIN_CHUNK`, which is the form the source uses).
   - Build: no config or build-system change.
   - Compatibility: `_ASSERT(f,file,line)` keeps its 3-argument signature (used 
by out-of-tree code, e.g. nuttx-apps' ostest); a companion nuttx-apps PR 
updates its one internal macro to the new form.
   - Security: no change.
   
   ## Testing
   
   - Host: qemu-intel64 (x86_64, gcc 13), `CONFIG_DEBUG_ASSERTIONS=y` + 
`CONFIG_DEBUG_ASSERTIONS_EXPRESSION=y`.
   - Build: `make` links clean (`LD: nuttx`).
   - `.rodata`: `strings -n 1000 nuttx` finds no large string (was a 
67,165-byte one); the assert strings read `nodesize >= MM_MIN_CHUNK` / 
`nodesize >= MM_SIZEOF_ALLOCNODE` (literal source text); the largest string in 
the image is 223 bytes (a GCC command line).


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