Skip to content

Commit 09a2456

Browse files
authored
Fix memory leak in GC when rootset enumeration fails (#4793)
Signed-off-by: zhenweijin <zhenwei.jin@intel.com>
1 parent a60c707 commit 09a2456

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

core/shared/mem-alloc/ems/ems_gc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,12 @@ reclaim_instance_heap(gc_heap_t *heap)
308308
return GC_SUCCESS;
309309
ret = gct_vm_begin_rootset_enumeration(heap->cluster, heap);
310310
#endif
311-
if (!ret)
311+
if (!ret) {
312+
if (heap->root_set) {
313+
rollback_mark(heap);
314+
}
312315
return GC_ERROR;
316+
}
313317

314318
#if BH_ENABLE_GC_VERIFY != 0
315319
/* no matter whether the enumeration is successful or not, the data

0 commit comments

Comments
 (0)