Skip to content

system/uorb: Select the printf extension the format strings need. - #3792

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
Fishwaldo:upstream-uorb-format-extension
Sep 20, 2026
Merged

xiaoxiang781216 merged 1 commit into
apache:masterfrom
Fishwaldo:upstream-uorb-format-extension

Conversation

@Fishwaldo

Copy link
Copy Markdown
Contributor

Summary

UORB_FORMAT compiles in the per-topic format strings, which reach their data through %pB. That is a NuttX printf extension, not a standard conversion, and UORB_FORMAT does not select it.

A configuration that enables the listener but not the debug output therefore builds cleanly, runs, and prints the pointer instead of the reading:

sensor_voltage(now:4294968998000):0xc0203c98B

The address is the va_format the extension was meant to expand, and the trailing B is the conversion character being taken as ordinary text. Nothing warns, because to the compiler and to printf this is a valid format string that means something else.

DEBUG_UORB already selects the extension, so the fault is invisible to anyone who has that on. The two are independent options and only one of them declared what it needed. Move the select onto UORB_FORMAT, the option that decides whether the format strings exist at all.

Impact

One line of system/uorb/Kconfig. Affects configurations with UORB_FORMAT=y and DEBUG_UORB=n, which gain LIBC_PRINT_EXTENSION. Configurations that already set DEBUG_UORB are unchanged, since it selects the extension today.

Testing

Reproduced on an ESWIN EIC7700 EVB with UORB_FORMAT=y and DEBUG_UORB=n: uorb_listener printed 0xc0203c98B for every sample. With this change the same build prints the value:

sensor_voltage(now:115415014):timestamp:115414993,voltage:12.037500

Every topic's format string is printed through orb_info() or
orb_fprintf(), and both reach the data through "%pB", which is a NuttX
extension rather than a standard conversion.  UORB_FORMAT turns that
code on without turning the extension on, so a configuration that
enables the listener but not the debug output builds cleanly, runs, and
prints a pointer where the reading should be:

  sensor_voltage(now:4294968998000):0xc0203c98B

The address is the va_format the extension was supposed to expand, and
the trailing B is the conversion character being taken as ordinary
text.  Nothing warns, because to the compiler and to printf this is a
valid format string that means something else.

DEBUG_UORB already selects the extension, so the fault is invisible to
anyone who turned that on.  The two are independent options and only
one of them declared what it needed.  Move the select onto UORB_FORMAT,
which is the option that decides whether the format strings are
compiled in at all.

Signed-off-by: Justin Hammond <justin@dynam.ac>

@cederom cederom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Fishwaldo :-)

@linguini1

Copy link
Copy Markdown
Contributor

Shouldn't we use "depends on"?

@xiaoxiang781216
xiaoxiang781216 merged commit 41a2c9d into apache:master Sep 20, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants