Skip to content

Commit

Permalink
make sure invalid indices for lexical vivify throw
Browse files Browse the repository at this point in the history
rather than segfaulting with an invalid object later on

this would be better in the bytecode validator, though.
  • Loading branch information
timo committed Apr 17, 2019
1 parent c10fee6 commit c8a44b8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/core/frame.c
Expand Up @@ -1241,8 +1241,15 @@ MVMObject * MVM_frame_vivify_lexical(MVMThreadContext *tc, MVMFrame *f, MVMuint1
MVMint32 scid, objid;
if (MVM_bytecode_find_static_lexical_scref(tc, effective_sf->body.cu,
effective_sf, effective_idx, &scid, &objid)) {
MVMSerializationContext *sc = MVM_sc_get_sc(tc, effective_sf->body.cu, scid);
MVMSerializationContext *sc;
MVMObject *resolved;
/* XXX This really ought to go into the bytecode validator
* instead for better performance and earlier crashing */
if (effective_sf->body.cu->body.num_scs <= scid) {
MVM_exception_throw_adhoc(tc,
"Bytecode corruption: illegal sc dependency of lexical: %d > %d", scid, effective_sf->body.cu->body.num_scs);
}
sc = MVM_sc_get_sc(tc, effective_sf->body.cu, scid);
if (sc == NULL)
MVM_exception_throw_adhoc(tc,
"SC not yet resolved; lookup failed");
Expand Down

3 comments on commit c8a44b8

@MasterDuke17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking, but shouldn't the error message say >= instead of just >?

@MasterDuke17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but if it's just describing the values, scid could in fact be == effective_sf->body.cu->body.num_scs when that exception is thrown.

@MasterDuke17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh hey, the comment my second comment was a reply to disappeared?

Please sign in to comment.