zephyr/kernel
Andy Ross f6239c52ae kernel/sched: Panic after aborting essential thread, not before
The essential thread check and panic happens at the top of
k_thread_abort().  This is arguably a performance bug: the system is
going to blow up anyway no matter where we put the test, we shouldn't
add instructions to the path taken by systems that DON'T blow up.

But really it's more of a testability/robustness glitch: if you have a
fatal error handler that wants to catch this panic (say, a test using
ztest_set_fault_valid()), then the current code will panic and
early-exit BEFORE THE THREAD IS DEAD.  And so it won't actually die,
and will continue on causing mayhem when presumably the handler code
expected it to have been aborted.

It's sort of an unanswerable question as to what the "right" behavior
is here (the system is, after all, supposed to have panicked!).  But
this seems preferable for definable practical reasons.

Kill the thread, then panic.  Unless it's _current, in which case
panic as late as possible for maximum coverage of the abort path.

Fixes: #84460

Signed-off-by: Andy Ross <andyross@google.com>
2025-02-10 22:26:10 +01:00
..
include kernel: Change z_handle_obj_poll_events() return type 2025-02-03 19:51:20 +01:00
paging
atomic_c.c
banner.c
busy_wait.c
CMakeLists.txt kernel: Rewrite k_pipe_* API 2025-01-17 19:43:44 +01:00
compiler_stack_protect.c security: Add default stack protection level 2024-12-20 12:37:20 +01:00
condvar.c kernel: condvar: broadcast does not always need reschedule 2025-02-03 19:51:20 +01:00
cpu_mask.c kernel: Simplify k_thread_cpu_pin() 2024-09-20 09:02:38 +02:00
device.c device: Optimize device_get_binding search efficiency 2024-11-27 08:18:30 +01:00
dynamic_disabled.c
dynamic.c kernel: dynamic: simplify dynamic stack allocation 2024-12-11 21:33:00 +01:00
errno.c Revert "arch: deprecate _current" 2025-01-10 07:49:08 +01:00
events.c
fatal.c Revert "arch: deprecate _current" 2025-01-10 07:49:08 +01:00
float.c
futex.c kernel: futex: Allow for fast return on k_futex_wake() 2025-02-03 19:51:20 +01:00
idle.c Revert "arch: deprecate _current" 2025-01-10 07:49:08 +01:00
init_static.c
init.c security: Additional option for stack canaries 2024-12-20 12:37:20 +01:00
ipi.c Revert "arch: deprecate _current" 2025-01-10 07:49:08 +01:00
irq_offload.c
Kconfig kernel: Rewrite k_pipe_* API 2025-01-17 19:43:44 +01:00
Kconfig.device
Kconfig.init init: support per-core init hook 2024-11-16 14:04:25 -05:00
Kconfig.mem_domain
Kconfig.obj_core kernel: Rewrite k_pipe_* API 2025-01-17 19:43:44 +01:00
Kconfig.smp kernel: remove CONFIG_MP_NUM_CPUS 2024-09-19 18:28:37 +01:00
Kconfig.vm
kheap.c kernel: Initialize kheap spinlock 2025-02-04 09:19:09 +01:00
mailbox.c Revert "arch: deprecate _current" 2025-01-10 07:49:08 +01:00
main_weak.c
mem_domain.c Revert "arch: deprecate _current" 2025-01-10 07:49:08 +01:00
mem_slab.c Revert "arch: deprecate _current" 2025-01-10 07:49:08 +01:00
mempool.c Revert "arch: deprecate _current" 2025-01-10 07:49:08 +01:00
mmu.c Revert "arch: deprecate _current" 2025-01-10 07:49:08 +01:00
msg_q.c kernel: msgq: Allow for fast returns 2025-02-03 19:51:20 +01:00
mutex.c Revert "arch: deprecate _current" 2025-01-10 07:49:08 +01:00
nothread.c kernel: fix k_sleep in no multi-threading mode 2024-11-16 14:07:41 -05:00
obj_core.c
pipe.c k_pipe: fix trace point for blocking writes 2025-01-28 14:13:14 +01:00
pipes.c kernel: Propagate z_handle_obj_poll_events() return 2025-02-03 19:51:20 +01:00
poll.c kernel: Change z_handle_obj_poll_events() return type 2025-02-03 19:51:20 +01:00
priority_queues.c
queue.c kernel: queue: Allow for fast return 2025-02-03 19:51:20 +01:00
sched.c kernel/sched: Panic after aborting essential thread, not before 2025-02-10 22:26:10 +01:00
sem.c kernel: Allow for fast return on k_sem_reset() 2025-02-03 19:51:20 +01:00
smp.c kernel: mark z_smp_current_get() with the const attribute 2025-01-10 07:49:08 +01:00
spinlock_validate.c Revert "arch: deprecate _current" 2025-01-10 07:49:08 +01:00
stack.c Revert "arch: deprecate _current" 2025-01-10 07:49:08 +01:00
system_work_q.c
thread_monitor.c style: kernel: comply with MISRA C:2012 Rule 15.6 2024-09-11 07:40:35 -04:00
thread.c kernel: thread: fix warning of always false 2025-02-10 22:25:32 +01:00
timeout.c kernel: Add timeout_lock usage notes 2025-01-28 18:14:22 +01:00
timer.c
timeslicing.c Revert "arch: deprecate _current" 2025-01-10 07:49:08 +01:00
usage.c
userspace_handler.c Revert "arch: deprecate _current" 2025-01-10 07:49:08 +01:00
userspace.c Revert "arch: deprecate _current" 2025-01-10 07:49:08 +01:00
version.c
work.c Revert "arch: deprecate _current" 2025-01-10 07:49:08 +01:00
xip.c security: Additional option for stack canaries 2024-12-20 12:37:20 +01:00