Skip to content

Commit 4a7b65b

Browse files
committed
Clean up active exception handlers when garbage collecting a thread
1 parent a18b4dc commit 4a7b65b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/core/threadcontext.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ MVMThreadContext * MVM_tc_create(MVMThreadContext *parent, MVMInstance *instance
8282
void MVM_tc_destroy(MVMThreadContext *tc) {
8383
MVMint32 i;
8484

85+
/* If an exception handler calls nqp::exit, we don't unwind the stack and
86+
* exception handlers aren't cleaned up yet */
87+
while (tc->active_handlers) {
88+
MVMActiveHandler *ah = tc->active_handlers;
89+
tc->active_handlers = ah->next_handler;
90+
MVM_free(ah);
91+
}
92+
8593
/* Free the native callback cache. Needs the fixed size allocator. */
8694
/* (currently not. but might if MVMStrHash moves internally to the FSA.) */
8795
MVM_str_hash_demolish(tc, &tc->native_callback_cache);

0 commit comments

Comments
 (0)