From 9cdf062ee63b97f7ee5dbc0142e5f43a21b1801a Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Mon, 10 Dec 2012 14:56:32 +0100 Subject: [PATCH] base: catch exceptions in rm_session For base-nova thread creation related exception can be thrown, since the Pager_objects are threads. Catch the exception and re-throw the expected/documented exception in rm_session. This commit avoids that core dies with an unhandled exception if a thread couldn't be created (e.g. because the limit has been reached). --- base/src/core/rm_session_component.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/base/src/core/rm_session_component.cc b/base/src/core/rm_session_component.cc index aae4c315fb..867a96bb3a 100644 --- a/base/src/core/rm_session_component.cc +++ b/base/src/core/rm_session_component.cc @@ -293,6 +293,7 @@ void Rm_faulter::fault(Rm_session_component *faulting_rm_session, void Rm_faulter::dissolve_from_faulting_rm_session() { + /* serialize access */ Lock::Guard lock_guard(_lock); if (_faulting_rm_session) @@ -326,8 +327,7 @@ Rm_session_component::attach(Dataspace_capability ds_cap, size_t size, Lock::Guard lock_guard(_lock); /* offset must be positive and page-aligned */ - if (offset < 0 - || align_addr(offset, get_page_size_log2()) != offset) + if (offset < 0 || align_addr(offset, get_page_size_log2()) != offset) throw Invalid_args(); /* check dataspace validity */ @@ -577,6 +577,8 @@ Pager_capability Rm_session_component::add_client(Thread_capability thread) Rm_client *cl; try { cl = new(&_client_slab) Rm_client(this, badge); } catch (Allocator::Out_of_memory) { throw Out_of_metadata(); } + catch (Cpu_session::Thread_creation_failed) { throw Out_of_metadata(); } + catch (Thread_base::Stack_alloc_failed) { throw Out_of_metadata(); } _clients.insert(cl);