mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-14 05:08:19 +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:
@ -258,10 +258,10 @@ inline int lx_sigaction(int signum, void (*handler)(int))
|
||||
* when leaving the signal handler and it should call the rt_sigreturn syscall.
|
||||
*/
|
||||
enum { SA_RESTORER = 0x04000000 };
|
||||
act.flags = SA_RESTORER;
|
||||
act.flags = SA_RESTORER | SA_ONSTACK;
|
||||
act.restorer = lx_restore_rt;
|
||||
#else
|
||||
act.flags = 0;
|
||||
act.flags = SA_ONSTACK;
|
||||
act.restorer = 0;
|
||||
#endif
|
||||
lx_sigemptyset(&act.mask);
|
||||
@ -282,6 +282,17 @@ inline int lx_tgkill(int pid, int tid, int signal)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Alternate signal stack (handles also SIGSEGV in a safe way)
|
||||
*/
|
||||
inline int lx_sigaltstack(void *signal_stack, Genode::size_t stack_size)
|
||||
{
|
||||
stack_t stack { signal_stack, 0, stack_size };
|
||||
|
||||
return lx_syscall(SYS_sigaltstack, &stack, nullptr);
|
||||
}
|
||||
|
||||
|
||||
inline int lx_create_thread(void (*entry)(), void *stack, void *arg)
|
||||
{
|
||||
int flags = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND
|
||||
|
Reference in New Issue
Block a user