From 75ab803ea218a2a7e2486477ee198169ef7c39a4 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Tue, 24 Feb 2015 13:18:35 +0100 Subject: [PATCH] foc: check result of bind_thread Issue #1418 --- repos/base-foc/src/base/thread/thread_start.cc | 7 ++++++- repos/base-foc/src/core/platform.cc | 6 ++++-- repos/base-foc/src/core/thread_start.cc | 4 +++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/repos/base-foc/src/base/thread/thread_start.cc b/repos/base-foc/src/base/thread/thread_start.cc index 5bfa10a35..1f1e80f7d 100644 --- a/repos/base-foc/src/base/thread/thread_start.cc +++ b/repos/base-foc/src/base/thread/thread_start.cc @@ -53,13 +53,18 @@ void Thread_base::_init_platform_thread(size_t, Type type) _thread_cap = _cpu_session->create_thread(0, buf); /* assign thread to protection domain */ - env()->pd_session()->bind_thread(_thread_cap); + if (!_thread_cap.valid() || + env()->pd_session()->bind_thread(_thread_cap)) + throw Cpu_session::Thread_creation_failed(); return; } /* adjust values whose computation differs for a main thread */ _tid = Fiasco::MAIN_THREAD_CAP; _thread_cap = env()->parent()->main_thread_cap(); + if (!_thread_cap.valid()) + throw Cpu_session::Thread_creation_failed(); + /* make thread object known to the Fiasco environment */ addr_t const t = (addr_t)this; Fiasco::l4_utcb_tcr()->user[Fiasco::UTCB_TCR_THREAD_OBJ] = t; diff --git a/repos/base-foc/src/core/platform.cc b/repos/base-foc/src/core/platform.cc index e43db9c3c..c091816cc 100644 --- a/repos/base-foc/src/core/platform.cc +++ b/repos/base-foc/src/core/platform.cc @@ -140,7 +140,8 @@ Platform::Core_pager::Core_pager(Platform_pd *core_pd, Sigma0 *sigma0) { Platform_thread::pager(sigma0); - core_pd->bind_thread(this); + if (core_pd->bind_thread(this)) + panic("Binding thread failed"); cap(thread().local); /* stack begins at the top end of the '_core_pager_stack' array */ @@ -499,7 +500,8 @@ Platform::Platform() : Platform_thread(thi, irqi, "core.main"); core_thread->pager(&_sigma0); - _core_pd->bind_thread(core_thread); + if (_core_pd->bind_thread(core_thread)) + panic("Binding thread failed"); } diff --git a/repos/base-foc/src/core/thread_start.cc b/repos/base-foc/src/core/thread_start.cc index ad678c20d..664f53ef8 100644 --- a/repos/base-foc/src/core/thread_start.cc +++ b/repos/base-foc/src/core/thread_start.cc @@ -46,7 +46,9 @@ void Thread_base::start() Platform_thread *pt = new(platform()->core_mem_alloc()) Platform_thread(_context->name); - platform_specific()->core_pd()->bind_thread(pt); + if (platform_specific()->core_pd()->bind_thread(pt)) + throw Cpu_session::Thread_creation_failed(); + _tid = pt->gate().remote; _thread_cap = reinterpret_cap_cast(Native_capability(pt->thread().local));