Repository navigation
include/assert: stringify assert expressions at the first macro level - #21764
Merged
Merged
Conversation
Fix-Point
force-pushed
the
fix-assert-stringify
branch
2 times, most recently
from
November 12, 2026 08:05
0832e9b to
0eb893c
Compare
jerpelea
approved these changes
Nov 12, 2026
The chain DEBUGASSERT(f) -> _ASSERT(f) -> #f macro-replaces f before the #f stringification (the DEBUGASSERT replacement list has no # or ##), so the assert strings held the expanded token sequences. With __INT128_DEFINED, FLS() expands to both FLS64() and FLS128() (a full ternary tree each), so one DEBUGASSERT(nodesize >= MM_MIN_CHUNK) in mm/mm_heap/mm.h reached 67,165 bytes -- the +49 KB .rodata on qemu-intel64 with CONFIG_DEBUG_ASSERTIONS_EXPRESSION. Stringify at the first macro level instead: _ASSERT()/_VERIFY() take the expression string as a parameter, and the five assert entry points (DEBUGASSERT/DEBUGVERIFY/ASSERT/VERIFY/assert) pass #f themselves. The strings now hold the source text, and the largest string in the qemu-intel64 image drops from 67,165 to 223 bytes. _ASSERT()/_VERIFY() gain a 4th parameter; the one in-tree caller outside assert.h (ostest's wdtest_assert() in nuttx-apps) is updated by a companion PR. Verified on qemu-intel64 with CONFIG_DEBUG_ASSERTIONS_EXPRESSION: the image links clean, strings -n 1000 finds no large string, and the assert strings read "nodesize >= MM_MIN_CHUNK". Assisted-By: mimo-v2.6-pro Signed-off-by: ouyangxiangzhen <[email protected]>
Fix-Point
force-pushed
the
fix-assert-stringify
branch
from
November 12, 2026 09:22
0eb893c to
f840f27
Compare
|
🔗 Cross-repo PR dependenciesThe read-only Build run reported the following dependent PR(s) and fetched head SHA(s): |
xiaoxiang781216
approved these changes
Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Related to: #21491
This PR fixes assert-expression stringification so macro-heavy assert conditions no longer bloat
.rodata.DEBUGASSERT()expanded its argument before stringification (theDEBUGASSERT(f) -> _ASSERT(f) -> #fchain macro-replacesfat the first boundary), so#fcaptured the expanded token sequence; with__INT128_DEFINED,FLS()expands to bothFLS64()andFLS128()(a full ternary tree each), and a singleDEBUGASSERT(nodesize >= MM_MIN_CHUNK)inmm/mm_heap/mm.hreached 67,165 bytes — the +49 KB.rodatareported on qemu-intel64 withCONFIG_DEBUG_ASSERTIONS_EXPRESSION.The fix stringifies at the first macro level:
_ASSERT()/_VERIFY()take the expression string as a 4th parameter, andDEBUGASSERT()/DEBUGVERIFY()/ASSERT()/VERIFY()/assert()pass#fthemselves. The one in-tree caller outsideassert.h— ostest'swdtest_assert()in nuttx-apps — is updated by a companion PR (Depends-On link there).Impact
nodesize >= MM_MIN_CHUNK, which is the form the source uses)._ASSERT(f,file,line)/_VERIFY(f,file,line)gain a 4th parameter; all in-tree callers are updated here and in the companion apps PR.Testing
CONFIG_DEBUG_ASSERTIONS=y+CONFIG_DEBUG_ASSERTIONS_EXPRESSION=y.makelinks clean (LD: nuttx)..rodata:strings -n 1000 nuttxfinds no large string (was a 67,165-byte one); the assert strings readnodesize >= MM_MIN_CHUNK/nodesize >= MM_SIZEOF_ALLOCNODE(literal source text); the largest string in the image is 223 bytes (a GCC command line).Depends-on: apache/nuttx-apps#4033