From 29e4d69f5ecce1120c5faceade331bb640a4ca5c Mon Sep 17 00:00:00 2001 From: zhenweijin Date: Mon, 19 Jan 2026 17:00:36 +0800 Subject: [PATCH] Fix memory leak in GC when rootset enumeration fails Signed-off-by: zhenweijin --- core/shared/mem-alloc/ems/ems_gc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/shared/mem-alloc/ems/ems_gc.c b/core/shared/mem-alloc/ems/ems_gc.c index e97a07bba3..bc0488968d 100644 --- a/core/shared/mem-alloc/ems/ems_gc.c +++ b/core/shared/mem-alloc/ems/ems_gc.c @@ -308,8 +308,12 @@ reclaim_instance_heap(gc_heap_t *heap) return GC_SUCCESS; ret = gct_vm_begin_rootset_enumeration(heap->cluster, heap); #endif - if (!ret) + if (!ret) { + if (heap->root_set) { + rollback_mark(heap); + } return GC_ERROR; + } #if BH_ENABLE_GC_VERIFY != 0 /* no matter whether the enumeration is successful or not, the data