From 5111482ab9bfac1f3e27124efb182ae7068a1b94 Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Thu, 10 Dec 2015 14:06:19 -0800 Subject: [PATCH] Fix stack overflow check in InvokeClosure. Isolate::saved_stack_limit() answers the limit of the Dart stack, which is different from the C stack when using the simulators. Since we are recursing in C, we want to check against the C stack's limit. This overflow check is only needed to support --no-lazy-dispatchers, which is part of precompilation. BUG=http://dartbug.com/24659 R=regis@google.com Review URL: https://codereview.chromium.org/1513993004 . --- runtime/vm/dart_entry.cc | 14 +++++++------- tests/language/language.status | 1 - 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/runtime/vm/dart_entry.cc b/runtime/vm/dart_entry.cc index 5a252e57a14d..4ae6851f5b19 100644 --- a/runtime/vm/dart_entry.cc +++ b/runtime/vm/dart_entry.cc @@ -167,15 +167,15 @@ RawObject* DartEntry::InvokeClosure(const Array& arguments, while (!cls.IsNull()) { function ^= cls.LookupDynamicFunction(getter_name); if (!function.IsNull()) { - // Getters don't have a stack overflow check, so do one in C++. - Isolate* isolate = Isolate::Current(); -#if defined(USING_SIMULATOR) - uword stack_pos = Simulator::Current()->get_register(SPREG); -#else - uword stack_pos = Isolate::GetCurrentStackPointer(); + uword c_stack_pos = Isolate::GetCurrentStackPointer(); + uword c_stack_limit = OSThread::Current()->stack_base() - + OSThread::GetSpecifiedStackSize(); +#if !defined(USING_SIMULATOR) + ASSERT(c_stack_limit == isolate->saved_stack_limit()); #endif - if (stack_pos < isolate->saved_stack_limit()) { + + if (c_stack_pos < c_stack_limit) { const Instance& exception = Instance::Handle(isolate->object_store()->stack_overflow()); return UnhandledException::New(exception, Stacktrace::Handle()); diff --git a/tests/language/language.status b/tests/language/language.status index 8c5eb92dcba5..0083eee9fa88 100644 --- a/tests/language/language.status +++ b/tests/language/language.status @@ -135,6 +135,5 @@ deopt_inlined_function_lazy_test: Pass, Crash # Incompatible flag: --deoptimize- tearoff_basic_test: RuntimeError, Crash # Conflicting flag. vm/type_cast_vm_test: RuntimeError # Line number mismatch. regress_23408_test: RuntimeError -issue21159_test: Pass, Crash, Timeout # Issue 24659 - missing stack overflow check stack_trace_test: Fail # Issue 24783 - inlined frames missing