*should mark the whole outer-scope chain when collecting garbage with a closure.
This commit is contained in:
parent
91ad8cd226
commit
abbe1f85be
@ -6405,9 +6405,11 @@ static int _gc_add_reachable(void* data, void* extra, void* h) {
|
|||||||
case _DT_ROUTINE:
|
case _DT_ROUTINE:
|
||||||
if(obj->data.routine->type == MB_RT_LAMBDA) {
|
if(obj->data.routine->type == MB_RT_LAMBDA) {
|
||||||
if(!_ht_find(ht, &obj->data.routine->func.lambda.ref)) {
|
if(!_ht_find(ht, &obj->data.routine->func.lambda.ref)) {
|
||||||
|
_running_context_ref_t* outs = obj->data.routine->func.lambda.outer_scope;
|
||||||
_ht_set_or_insert(ht, &obj->data.routine->func.lambda.ref, obj->data.routine);
|
_ht_set_or_insert(ht, &obj->data.routine->func.lambda.ref, obj->data.routine);
|
||||||
if(obj->data.routine->func.lambda.outer_scope) {
|
while(outs) {
|
||||||
_HT_FOREACH(obj->data.routine->func.lambda.outer_scope->scope->var_dict, _do_nothing_on_object, _gc_add_reachable, ht);
|
_HT_FOREACH(outs->scope->var_dict, _do_nothing_on_object, _gc_add_reachable, ht);
|
||||||
|
outs = outs->prev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user