From 4e47cd256823b2116d4dfea623def874379c5e5c Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Tue, 9 Jul 2013 17:06:02 +0200 Subject: [PATCH] nova: catch exception when leaving thread::entry() Catch exceptions and try to make a printf. If this also fails, catch it and die causing some noise output in core to detect the situation. --- base-nova/src/base/thread/thread_nova.cc | 25 ++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/base-nova/src/base/thread/thread_nova.cc b/base-nova/src/base/thread/thread_nova.cc index 2a928c22e..db98dfaea 100644 --- a/base-nova/src/base/thread/thread_nova.cc +++ b/base-nova/src/base/thread/thread_nova.cc @@ -36,8 +36,29 @@ using namespace Genode; */ void Thread_base::_thread_start() { - Genode::Thread_base::myself()->entry(); - Thread_base::myself()->_join_lock.unlock(); + using namespace Genode; + + /* if the inner catch handling fails, let thread die with some noise */ + try { + + /* catch any exception at this point and try to print a error message */ + try { + Thread_base::myself()->entry(); + } catch (...) { + char thread_name[48]; + Thread_base::myself()->name(thread_name, sizeof(thread_name)); + + PERR("Thread '%s' died because of an uncaught exception", thread_name); + } + + Thread_base::myself()->_join_lock.unlock(); + + } catch (...) { + /* die in a noisy way */ + nova_die(); + } + + /* sleep silently */ Genode::sleep_forever(); }