Skip to content

Commit

Permalink
shell: modules: do not use k_thread_foreach with shell callbacks
Browse files Browse the repository at this point in the history
Always use k_thread_foreach_unlocked with callbacks which print
something out to the shell, as they might call arch_irq_unlock.
Fixes #66660.

Signed-off-by: Benedikt Schmidt <[email protected]>
(cherry picked from commit 4c731f2)
  • Loading branch information
benediktibk authored and cfriedt committed Feb 27, 2024
1 parent b8ff36f commit dd63f90
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions subsys/shell/modules/kernel_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,12 @@ static int cmd_kernel_threads(const struct shell *shell,
shell_print(shell, "Scheduler: %u since last call", sys_clock_elapsed());
shell_print(shell, "Threads:");

#ifdef CONFIG_SMP
k_thread_foreach_unlocked(shell_tdata_dump, (void *)shell);
#else
k_thread_foreach(shell_tdata_dump, (void *)shell);
#endif
/*
* Use the unlocked version as the callback itself might call
* arch_irq_unlock.
*/
k_thread_foreach_unlocked(shell_tdata_dump, (void *)sh);

return 0;
}

Expand Down Expand Up @@ -190,11 +191,11 @@ static int cmd_kernel_stacks(const struct shell *shell,
ARG_UNUSED(argc);
ARG_UNUSED(argv);

#ifdef CONFIG_SMP
k_thread_foreach_unlocked(shell_stack_dump, (void *)shell);
#else
k_thread_foreach(shell_stack_dump, (void *)shell);
#endif
/*
* Use the unlocked version as the callback itself might call
* arch_irq_unlock.
*/
k_thread_foreach_unlocked(shell_stack_dump, (void *)sh);

/* Placeholder logic for interrupt stack until we have better
* kernel support, including dumping arch-specific exception-related
Expand Down

0 comments on commit dd63f90

Please sign in to comment.