linux: print warning for unusually small stacks

Thread stacks with less than 4K usable space are insufficient for our
implementation of Linux exception signal handling. If such a unusually
small stack overflows the SIGSEGV handler will not be able to print the
diagnostic message leaving no hint of the cause of the stuck process.
This commit is contained in:
Christian Helmuth 2016-07-19 14:39:14 +02:00
parent 887b6233b1
commit f14024eb52
1 changed files with 4 additions and 0 deletions

View File

@ -17,6 +17,7 @@
#include <base/thread.h>
#include <base/snprintf.h>
#include <base/sleep.h>
#include <base/log.h>
#include <linux_native_cpu/client.h>
#include <cpu_thread/client.h>
@ -55,6 +56,9 @@ void Thread::_thread_start()
size_t stack_size = thread->_stack->top() - thread->_stack->base();
lx_sigaltstack(stack_base, stack_size);
if (stack_size < 0x1000)
raw("small stack of ", stack_size, " bytes for \"", thread->name(),
"\" may may break Linux signal handling");
/*
* Set signal handler such that canceled system calls get not