mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-20 08:03:56 +00:00
linux: place alternate signal stack in stack area
The alternate stack must use the stack area as, e.g., Thread::myself() depends on this property. Hybrid components do not depend on this property and, therefore, use a static stack buffer. Fixes #1935
This commit is contained in:
@ -46,19 +46,21 @@ static Lock &startup_lock()
|
||||
static void thread_exit_signal_handler(int) { lx_exit(0); }
|
||||
|
||||
|
||||
static char signal_stack[0x2000] __attribute__((aligned(0x1000)));
|
||||
|
||||
void Thread::_thread_start()
|
||||
{
|
||||
lx_sigaltstack(signal_stack, sizeof(signal_stack));
|
||||
Thread * const thread = Thread::myself();
|
||||
|
||||
/* use primary stack as alternate stack for fatal signals (exceptions) */
|
||||
void *stack_base = (void *)thread->_stack->base();
|
||||
size_t stack_size = thread->_stack->top() - thread->_stack->base();
|
||||
|
||||
lx_sigaltstack(stack_base, stack_size);
|
||||
|
||||
/*
|
||||
* Set signal handler such that canceled system calls get not
|
||||
* transparently retried after a signal gets received.
|
||||
*/
|
||||
lx_sigaction(LX_SIGUSR1, empty_signal_handler);
|
||||
|
||||
Thread * const thread = Thread::myself();
|
||||
lx_sigaction(LX_SIGUSR1, empty_signal_handler, false);
|
||||
|
||||
/* inform core about the new thread and process ID of the new thread */
|
||||
Linux_native_cpu_client native_cpu(thread->_cpu_session->native_cpu());
|
||||
@ -141,7 +143,7 @@ void Thread::start()
|
||||
*/
|
||||
static bool threadlib_initialized = false;
|
||||
if (!threadlib_initialized) {
|
||||
lx_sigaction(LX_SIGCANCEL, thread_exit_signal_handler);
|
||||
lx_sigaction(LX_SIGCANCEL, thread_exit_signal_handler, false);
|
||||
threadlib_initialized = true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user