| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Create the server thread-local stdout key before marking the daemon as running, preventing early startup logs from using an invalid FILE pointer.
🔎 FLASH Analysispx4_fmu-v5x [Total VM Diff: 0 byte (0 %)] FILE SIZE VM SIZE
-------------- --------------
+0.0% +55 [ = ] 0 .debug_abbrev
-0.0% -2 [ = ] 0 .debug_info
-0.0% -13 [ = ] 0 .debug_line
-85.7% -6 [ = ] 0 [Unmapped]
-0.0% -7 [ = ] 0 [section .debug_line]
+0.0% +40 [ = ] 0 TOTAL
FILE SIZE VM SIZE
-------------- --------------
+0.0% +55 [ = ] 0 .debug_abbrev
-0.0% -2 [ = ] 0 .debug_info
-0.0% -13 [ = ] 0 .debug_line
-85.7% -6 [ = ] 0 [Unmapped]
-0.0% -7 [ = ] 0 [section .debug_line]
+0.0% +40 [ = ] 0 TOTAL
Updated: 2026-07-22T16:54:15 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Solved Problem
Fixes a px4_daemon startup race where the daemon could be considered running before its thread-local stdout
pthread_key_t was created. Early startup logging could then try to use daemon stdout handling with an invalid/
uninitialized TLS key, leading to invalid FILE * behavior.
Solution
Create the daemon stdout TLS key during Server construction, before the server is exposed as the active daemon
instance. Track whether the key was created successfully, fail Server::start() if it was not, and delete the key
only when valid.
get_stdout() now also checks that the server has a valid pthread key before using daemon thread-local stdout, so
early or fallback logging safely uses normal stdout.
Changelog Entry
For release notes:
Alternatives
The key could remain created inside the server thread with additional guards around stdout access, but that keeps
startup ordering fragile. Creating the key before the daemon is marked available makes the lifetime and readiness
contract explicit.
Test coverage
Tested on VOXL2 board