From 8a99c08ae49c10c06027466d913229d5289be246 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Thu, 21 May 2015 13:01:33 +0200 Subject: [PATCH] hw: always panic on removal of scheduler head Because of helping, it is possible that a core thread that wants to destroy another thread at the kernel is using the scheduling context of the thread that shall be destroyed at this point in time. When building without GENODE_RELEASE defined, this always triggers an assertion in the kernel. But when building with GENODE_RELEASE defined, this might silently lead to kernel-memory corruption. This commit eliminates the latter case. Should be reverted as soon as the scheduler is able to remove its head. Ref #1537 --- repos/base-hw/src/core/kernel/cpu_scheduler.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/repos/base-hw/src/core/kernel/cpu_scheduler.cc b/repos/base-hw/src/core/kernel/cpu_scheduler.cc index bc4f64efe8..2a26fb07fd 100644 --- a/repos/base-hw/src/core/kernel/cpu_scheduler.cc +++ b/repos/base-hw/src/core/kernel/cpu_scheduler.cc @@ -180,7 +180,18 @@ void Cpu_scheduler::yield() { _head_yields = 1; } void Cpu_scheduler::remove(Share * const s) { - assert(s != _idle && s != _head); + assert(s != _idle); + + /* + * FIXME + * Thanks to helping, this can happen and shall not be treated as bad + * behavior. But by now, we have no stable solution for it. + * + */ + if (s == _head) { + PERR("Removing the head of the CPU scheduler isn't supported by now."); + while (1) ; + } if (s->_ready) { _fills.remove(s); } if (!s->_quota) { return; } if (s->_ready) { _rcl[s->_prio].remove(s); }