From 5d43eeaee741b549b46bb7847c99823d983fd1af Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Wed, 8 Sep 2021 15:24:45 +0200 Subject: [PATCH] Fix search for bind control records It is possible that the bind control record is in a stack segment prior to the one that a frame is allocated in. In code that recurses enough to trigger multiple stack segments, this situation may occur, and could lead to multiple dispatch of candidates with `where` clauses and similar wrongly reporting an error instead of continuing to the next candidate. --- src/core/args.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/args.c b/src/core/args.c index 538039f19d..fb501739f6 100644 --- a/src/core/args.c +++ b/src/core/args.c @@ -1081,6 +1081,8 @@ void MVM_args_bind_failed(MVMThreadContext *tc, MVMDispInlineCacheEntry **ice_pt * bind failure handler. This is determined by if there is a bind failure * frame under us on the callstack in a fresh state. */ MVMCallStackRecord *under_us = tc->stack_top->prev; + while (under_us && under_us->kind == MVM_CALLSTACK_RECORD_START_REGION) + under_us = under_us->prev; if (under_us->kind == MVM_CALLSTACK_RECORD_BIND_CONTROL) { MVMCallStackBindControl *control_record = (MVMCallStackBindControl *)under_us; MVMBindControlState state = control_record->state; @@ -1117,6 +1119,8 @@ void MVM_args_bind_failed(MVMThreadContext *tc, MVMDispInlineCacheEntry **ice_pt * dispatch resumption. */ void MVM_args_bind_succeeded(MVMThreadContext *tc, MVMDispInlineCacheEntry **ice_ptr) { MVMCallStackRecord *under_us = tc->stack_top->prev; + while (under_us && under_us->kind == MVM_CALLSTACK_RECORD_START_REGION) + under_us = under_us->prev; if (under_us->kind == MVM_CALLSTACK_RECORD_BIND_CONTROL) { MVMCallStackBindControl *control_record = (MVMCallStackBindControl *)under_us; MVMBindControlState state = control_record->state;