Skip to content

Commit

Permalink
Fix stack overflow check in InvokeClosure.
Browse files Browse the repository at this point in the history
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 .
  • Loading branch information
rmacnak-google committed Dec 10, 2015
1 parent f0eb582 commit 5111482
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
14 changes: 7 additions & 7 deletions runtime/vm/dart_entry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
1 change: 0 additions & 1 deletion tests/language/language.status
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5111482

Please sign in to comment.