From d7da035115683185a6e224596714629a8b060490 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Tue, 8 Sep 2015 13:22:41 +0200 Subject: [PATCH] nova: sanitize priority parameters threads with prio 0 will not be started and would fail silently. Happened on Turmvilla for the USBProxy thread in virtualbox. Discovered during Turmvilla scenario #1552 and issue #1733. --- repos/base-nova/src/core/platform_thread.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/repos/base-nova/src/core/platform_thread.cc b/repos/base-nova/src/core/platform_thread.cc index aa375a455..3e382b7a6 100644 --- a/repos/base-nova/src/core/platform_thread.cc +++ b/repos/base-nova/src/core/platform_thread.cc @@ -346,6 +346,16 @@ Platform_thread::Platform_thread(const char *name, unsigned prio, int thread_id) _priority(Cpu_session::scale_priority(Nova::Qpd::DEFAULT_PRIORITY, prio)) { strncpy(_name, name, sizeof(_name)); + + if (_priority == 0) { + PWRN("priority of thread '%s' below minimum - boost to 1", _name); + _priority = 1; + } + if (_priority > Nova::Qpd::DEFAULT_PRIORITY) { + PWRN("priority of thread '%s' above maximum - limit to %u", + _name, Nova::Qpd::DEFAULT_PRIORITY); + _priority = Nova::Qpd::DEFAULT_PRIORITY; + } }