JianyuWang0623 opened a new pull request, #3838:
URL: https://github.com/apache/nuttx-apps/pull/3838

   *Note: Please adhere to [Contributing 
Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).*
   
   ## Summary
   
   An `on` section in the rc file can end up with no commands: the section line 
is
   accepted 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 
head
   of its empty command list, which `list_peek_head_type()` reports as NULL, and
   dereferences it, so init dies at boot.
   
   Skip actions that have no commands. A cmocka regression test follows.
   
   ## Impact
   
   An rc file containing an empty `on` section no longer crashes init at boot; 
the
   section 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`, `nuttx` at 
`284d4d4e`,
   `nuttx-apps` at `27ecdd7`.
   
   On top of `sim:nsh`:
   
   ```
   CONFIG_EXPERIMENTAL=y
   CONFIG_LIBC_EXECFUNCS=y
   CONFIG_SCHED_CHILD_STATUS=y
   CONFIG_SYSTEM_NXINIT=y
   CONFIG_ALLOW_MIT_COMPONENTS=y
   CONFIG_LIBC_REGEX=y
   CONFIG_TESTING_CMOCKA=y
   CONFIG_SYSTEM_NXINIT_TEST=y
   ```
   
   Before:
   
   ```
   [  FAILED  ] test_nxinit_action_empty_skipped
   ```
   
   and with the test's ready-queue assertion dropped so that
   `init_action_run_command()` is reached:
   
   ```
   timeout: the monitored command dumped core
   ```
   
   After:
   
   ```
   [==========] nxinit_tests: 20 test(s) run.
   [  PASSED  ] 20 test(s).
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to