mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-19 07:38:28 +00:00
linux: improve exception-signal handling
First, we use an alternate stack for signal handling now. The stack is shared among all threads of the component, which is okay as we only handle exceptions with log output and pass on to the default handler (that terminates the execution). The primary motivation for the alternate stack is the detection of SIGSEGV due to stack overflows. Also, hybrid components now handle exception signals by logging and the support for multi-threaded applications was improved. Fixes #1935
This commit is contained in:
@ -50,8 +50,12 @@ int genode___cxa_atexit(void (*func)(void*), void *arg, void *dso)
|
||||
extern char **environ;
|
||||
extern char **lx_environ;
|
||||
|
||||
static char signal_stack[0x2000] __attribute__((aligned(0x1000)));
|
||||
|
||||
static void empty_signal_handler(int) { }
|
||||
|
||||
extern void lx_exception_signal_handlers();
|
||||
|
||||
/*
|
||||
* This function must be called before any other static constructor in the Genode
|
||||
* application, so it gets the highest priority (lowest priority number >100)
|
||||
@ -60,6 +64,9 @@ __attribute__((constructor(101))) void lx_hybrid_init()
|
||||
{
|
||||
lx_environ = environ;
|
||||
|
||||
lx_sigaltstack(signal_stack, sizeof(signal_stack));
|
||||
lx_exception_signal_handlers();
|
||||
|
||||
/*
|
||||
* Set signal handler such that canceled system calls get not
|
||||
* transparently retried after a signal gets received.
|
||||
@ -348,6 +355,8 @@ Linux_cpu_session *cpu_session(Cpu_session * cpu_session)
|
||||
|
||||
static void adopt_thread(Native_thread::Meta_data *meta_data)
|
||||
{
|
||||
lx_sigaltstack(signal_stack, sizeof(signal_stack));
|
||||
|
||||
/*
|
||||
* Set signal handler such that canceled system calls get not
|
||||
* transparently retried after a signal gets received.
|
||||
|
Reference in New Issue
Block a user