Skip to content

Commit

Permalink
Don't lose exception handler results
Browse files Browse the repository at this point in the history
Invoking finalizers could end up replacing tc->last_handler_result,
leading to missing or incorrect values being observed for that after
finalizers had run. Don't run finalizers when there is such a risk.
  • Loading branch information
jnthn committed Nov 3, 2021
1 parent a3a2dd4 commit 7917743
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/gc/finalize.c
Expand Up @@ -84,10 +84,13 @@ void MVM_finalize_walk_queues(MVMThreadContext *tc, MVMuint8 gen) {

/* Try to run a finalization handler. Returns a true value if we do so */
MVMint32 MVM_gc_finalize_run_handler(MVMThreadContext *tc) {
/* Make sure there is a current frame and that there's a HLL handler
* to run. */
/* Make sure there is a current frame, that we aren't hanging on to an
* exception handler result (which the finalizer could overwrite), and
* that there's a HLL handler to run. */
if (!tc->cur_frame)
return 0;
if (tc->last_handler_result)
return 0;
MVMCode *handler = MVM_hll_current(tc)->finalize_handler;
if (handler) {
/* Drain the finalizing queue to an array. */
Expand Down

0 comments on commit 7917743

Please sign in to comment.