Skip to content

Commit

Permalink
Fix possible access to fromspace in MVM_frame_lexical_lookup_using_fr…
Browse files Browse the repository at this point in the history
…ame_walker

MVM_spesh_frame_walker_get_lex may need to viviy the lexical, which causes
allocation and may trigger a GC run. This may cause the name pointer to become
outdated when it's still needed in the error branch.
  • Loading branch information
niner committed Apr 24, 2020
1 parent 8a7e56d commit 51ab0cb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/core/frame.c
Expand Up @@ -1442,12 +1442,14 @@ MVMRegister * MVM_frame_find_lexical_by_name_rel(MVMThreadContext *tc, MVMString
* that is done depends on the frame walker setup. */
MVMRegister * MVM_frame_lexical_lookup_using_frame_walker(MVMThreadContext *tc,
MVMSpeshFrameWalker *fw, MVMString *name) {
MVM_gc_root_temp_push(tc, (MVMCollectable **)&(name));
while (MVM_spesh_frame_walker_next(tc, fw)) {
MVMRegister *found;
MVMuint16 found_kind;
if (MVM_spesh_frame_walker_get_lex(tc, fw, name, &found, &found_kind, 1, NULL)) {
MVM_spesh_frame_walker_cleanup(tc, fw);
if (found_kind == MVM_reg_obj) {
MVM_gc_root_temp_pop(tc);
return found;
}
else {
Expand All @@ -1460,6 +1462,7 @@ MVMRegister * MVM_frame_lexical_lookup_using_frame_walker(MVMThreadContext *tc,
}
}
MVM_spesh_frame_walker_cleanup(tc, fw);
MVM_gc_root_temp_pop(tc);
return NULL;
}

Expand Down

0 comments on commit 51ab0cb

Please sign in to comment.