From 6d8330afb6c925d1092f27919f61d4ce6a3fb1d4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Oct 2013 01:40:33 -0700 Subject: Use __morestack to detect stack overflow This commit resumes management of the stack boundaries and limits when switching between tasks. This additionally leverages the __morestack function to run code on "stack overflow". The current behavior is to abort the process, but this is probably not the best behavior in the long term (for deails, see the comment I wrote up in the stack exhaustion routine). --- src/rt/sync/rust_thread.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/rt/sync/rust_thread.cpp') diff --git a/src/rt/sync/rust_thread.cpp b/src/rt/sync/rust_thread.cpp index 824642fc435..a78153523d2 100644 --- a/src/rt/sync/rust_thread.cpp +++ b/src/rt/sync/rust_thread.cpp @@ -14,11 +14,7 @@ const size_t default_stack_sz = 1024*1024; -rust_thread::rust_thread() : thread(0), stack_sz(default_stack_sz) { -} - -rust_thread::rust_thread(size_t stack_sz) - : thread(0), stack_sz(stack_sz) { +rust_thread::rust_thread() : thread(0) { } rust_thread::~rust_thread() { @@ -40,10 +36,11 @@ rust_thread_start(void *ptr) { void rust_thread::start() { #if defined(__WIN32__) - thread = CreateThread(NULL, stack_sz, rust_thread_start, this, 0, NULL); + thread = CreateThread(NULL, default_stack_sz, rust_thread_start, this, 0, NULL); #else // PTHREAD_STACK_MIN of some system is larger than default size // so we check stack_sz to prevent assertion failure. + size_t stack_sz = default_stack_sz; if (stack_sz < PTHREAD_STACK_MIN) { stack_sz = PTHREAD_STACK_MIN; } -- cgit 1.4.1-3-g733a5