Skip to content

Commit 25398f3

Browse files
benediktibkcfriedt
authored andcommitted
shell: modules: do not use k_thread_foreach with shell callbacks
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)
1 parent d3c2a24 commit 25398f3

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

subsys/shell/modules/kernel_service.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,12 @@ static int cmd_kernel_threads(const struct shell *shell,
141141
shell_print(shell, "Scheduler: %u since last call", sys_clock_elapsed());
142142
shell_print(shell, "Threads:");
143143

144-
#ifdef CONFIG_SMP
144+
/*
145+
* Use the unlocked version as the callback itself might call
146+
* arch_irq_unlock.
147+
*/
145148
k_thread_foreach_unlocked(shell_tdata_dump, (void *)shell);
146-
#else
147-
k_thread_foreach(shell_tdata_dump, (void *)shell);
148-
#endif
149+
149150
return 0;
150151
}
151152

@@ -190,11 +191,11 @@ static int cmd_kernel_stacks(const struct shell *shell,
190191
ARG_UNUSED(argc);
191192
ARG_UNUSED(argv);
192193

193-
#ifdef CONFIG_SMP
194+
/*
195+
* Use the unlocked version as the callback itself might call
196+
* arch_irq_unlock.
197+
*/
194198
k_thread_foreach_unlocked(shell_stack_dump, (void *)shell);
195-
#else
196-
k_thread_foreach(shell_stack_dump, (void *)shell);
197-
#endif
198199

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

0 commit comments

Comments
 (0)