Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nshlib/builtin: check background task before restore the signal #2990

Merged
merged 1 commit into from
Feb 12, 2025

Conversation

anchao
Copy link
Contributor

@anchao anchao commented Feb 7, 2025

Summary

nshlib/builtin: check background task before restore the signal

fix crash if:
CONFIG_SCHED_WAITPID=n
CONFIG_SCHED_CHILD_STATUS=y

The old signal will be restored only when sigaction is saved to avoid invaild access.

Signed-off-by: chao an [email protected]

Impact

N/A

Testing

  1. build qemu-armv7a/rpserver_ivshmem
    cmake -B build -DBOARD_CONFIG=qemu-armv7a/rpserver_ivshmem -GNinja
  2. enable CONFIG_SCHED_CHILD_STATUS=y
    cmake --build build -t menuconfig
  3. start qemu
    qemu-system-arm -cpu cortex-a7 -nographic -machine virt,highmem=off -kernel build/nuttx -nographic
  4. exec hello and system will hangup

fix crash if:
CONFIG_SCHED_WAITPID=n
CONFIG_SCHED_CHILD_STATUS=y

The old signal will be restored only when sigaction is saved to avoid invaild access.

Signed-off-by: chao an <[email protected]>
@@ -234,7 +234,13 @@ int nsh_builtin(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,

/* Restore the old actions */

sigaction(SIGCHLD, &old, NULL);
# ifndef CONFIG_SCHED_WAITPID
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update the above commit to reflect this modification

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR only solves the crash issue, it should not appear in the code comments, and the comments above have already indicated the relevant behavior

@@ -234,7 +234,13 @@ int nsh_builtin(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,

/* Restore the old actions */

sigaction(SIGCHLD, &old, NULL);
# ifndef CONFIG_SCHED_WAITPID
Copy link
Contributor

Choose a reason for hiding this comment

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

don't need "# ifndef CONFIG_SCHED_WAITPID", keep align with line 92

Copy link
Contributor Author

Choose a reason for hiding this comment

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

line 135 already have this check if CONFIG_SCHED_WAITPID is defined

@acassis acassis merged commit 7f424c3 into apache:master Feb 12, 2025
37 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