Repository navigation
system/nxinit: skip actions without commands - #3838
Merged
xiaoxiang781216 merged 2 commits intoOct 13, 2026
Merged
Conversation
An "on" section can end up with an empty command list: the section line is accepted on its own, and a board whose init.rc goes through the C preprocessor can have every command inside the section compiled out. add_ready() queued such an action anyway, and init_action_run_command() then took the head of its empty command list, which list_peek_head_type() reports as NULL, and dereferenced it. Do not queue an action that has no commands. Assisted-by: Kiro:claude-opus-5 Signed-off-by: Kai Cheng <chengkai@xiaomi.com> Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Parse an "on" section with no command under it, trigger its event, and check that it never reaches the ready queue and that init_action_run_command() reports INT_MAX instead of taking the head of an empty command list. Without the preceding fix this test fails at the ready-queue assertion, and removing that assertion so the run path is reached crashes on a NULL dereference. Assisted-by: Kiro:claude-opus-5 Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
xiaoxiang781216
approved these changes
Oct 12, 2026
cederom
approved these changes
Oct 12, 2026
cederom
left a comment
Contributor
There was a problem hiding this comment.
Good catch thank you @JianyuWang0623 :-)
JianyuWang0623
marked this pull request as ready for review
October 12, 2026 10:32
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.
Note: Please adhere to Contributing Guidelines.
Summary
An
onsection in the rc file can end up with no commands: the section line isaccepted on its own, and a build that runs the rc file through the C
preprocessor can have every command inside a section compiled out.
add_ready()queues such an action anyway, and
init_action_run_command()then takes the headof its empty command list, which
list_peek_head_type()reports as NULL, anddereferences it, so init dies at boot.
Skip actions that have no commands. A cmocka regression test follows.
Impact
An rc file containing an empty
onsection no longer crashes init at boot; thesection is simply never queued. Nothing else changes: no new Kconfig symbol, no
new dependency, and the test code builds only under the existing
CONFIG_SYSTEM_NXINIT_TEST.Testing
Host Ubuntu 22.04.5 x86_64, gcc 13.4.0; target
sim:nsh,nuttxat284d4d4e,nuttx-appsat27ecdd7.On top of
sim:nsh:Before:
and with the test's ready-queue assertion dropped so that
init_action_run_command()is reached:After: