system/uorb: bump listener stack when float print extension is on - #3763
Open
FelipeMdeO wants to merge 1 commit into
Open
system/uorb: bump listener stack when float print extension is on#3763FelipeMdeO wants to merge 1 commit into
FelipeMdeO wants to merge 1 commit into
Conversation
uorb_listener's %pB debug printing (orb_info() -> lib_bsprintf()) does real floating-point-to-string conversion synchronously, in the listener's own task -- not a lightweight pointer dump. With CONFIG_LIBC_PRINT_EXTENSION off, %pB just prints a raw pointer and the default CONFIG_UORB_STACKSIZE (DEFAULT_TASK_STACKSIZE, 2048 on most configs) is plenty. With it on, decoding a topic's float fields through this path silently overflows a 2048-byte stack -- confirmed on real hardware (ESP32-S3, one push every ~10-20ms from two subscribed topics): uorb_listener hangs completely after printing only a partial topic name, no panic, no stack dump, nothing -- because CONFIG_SCHED_STACKGUARD/CONFIG_STACK_COLORATION aren't on by default either, so there's no guard to catch the overflow before it corrupts adjacent memory. Raising the default only when CONFIG_LIBC_PRINT_EXTENSION is set (not unconditionally, and not keyed off CONFIG_DEBUG_UORB specifically, since anything else that selects the same libc extension hits the same path) keeps the common case -- raw pointer output, small stack -- exactly as before, and only pays for the extra stack when the feature that needs it is actually enabled. 4096 was verified sufficient (tested against 2048, which reproduces the hang, and 8192, which also works but wastes RAM); reproduced cleanly across multiple fresh boots. Note: this default only applies when CONFIG_UORB_STACKSIZE has never been explicitly recorded in .config. Like any Kconfig int default, flipping CONFIG_LIBC_PRINT_EXTENSION on in an existing .config that already has an explicit CONFIG_UORB_STACKSIZE value won't retroactively raise it; the value has to be re-picked (e.g. via a fresh olddefconfig after removing the stale line, or manually). Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
xiaoxiang781216
approved these changes
Aug 30, 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
uorb_listener's%pBdebug printing (orb_info()->lib_bsprintf()) performs real floating-point-to-string conversion synchronously, inside the listener's own task -- it is not a lightweight pointer dump. WithCONFIG_LIBC_PRINT_EXTENSIONoff,%pBjust prints a raw pointer and the defaultCONFIG_UORB_STACKSIZE(DEFAULT_TASK_STACKSIZE, 2048 on most configs) is plenty. With it on, decoding a topic's float fields through this path silently overflows a 2048-byte stack.Confirmed on real hardware (ESP32-S3, two subscribed float topics pushing every ~10-20ms):
uorb_listenerhangs completely after printing only a partial topic name -- no panic, no stack dump, nothing -- becauseCONFIG_SCHED_STACKGUARD/CONFIG_STACK_COLORATIONaren't on by default either, so there's no guard to catch the overflow before it corrupts adjacent memory.Raising the default only when
CONFIG_LIBC_PRINT_EXTENSIONis set (not unconditionally, and not keyed offCONFIG_DEBUG_UORBspecifically, since anything else that selects the same libc extension hits the same path) keeps the common case -- raw pointer output, small stack -- exactly as before, and only pays for the extra stack when the feature that needs it is actually enabled.Impact
CONFIG_UORB_STACKSIZEdefault changes fromDEFAULT_TASK_STACKSIZEto 4096 only for configs withCONFIG_LIBC_PRINT_EXTENSION=y. No change for any other config. Users who already have an explicitCONFIG_UORB_STACKSIZErecorded in their.configare unaffected by this default either way (see note below).Testing
Host: Ubuntu 24.04.4 LTS.
xtensa-esp-elf-gcc(crosstool-NG esp-14.2.0_20241119) 14.2.0.checkpatch.sh(style +-mcommit message) clean.On hardware -- Seeed XIAO ESP32-S3,
CONFIG_LIBC_PRINT_EXTENSION=y,uorb_listenersubscribed to two float-based topics streaming continuously:CONFIG_UORB_STACKSIZE=2048(the old default): reproduces the hang every time, output cuts off mid topic-name print, console never responds again.CONFIG_UORB_STACKSIZE=4096(this PR's new default): runs cleanly, verified repeatedly across multiple fresh boots for 10+ seconds continuous, fully decoded output, e.g.:End-to-end with the actual Kconfig default mechanism (not a manual override): starting from a
.configwhereCONFIG_UORB_STACKSIZEwas never set, enablingCONFIG_LIBC_PRINT_EXTENSIONand runningmake olddefconfigresolvesCONFIG_UORB_STACKSIZEto 4096 automatically; the resulting build was flashed and validated live on the bench with the same clean, continuous decoded output as above.