Skip to contentSkip to conversation

linux-user: fix memory leak when threads exit

PATCH New [email protected] 1 participant 1 message May 28, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: fix memory leak when threads exit

From: kkHAIKE <[email protected]>

when call do_fork->cpu_copy->cpu_create, the return new cpu was not parent so refby '/unattached', so need add more object_unparent call to unref.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/866

---
 linux-user/syscall.c | 1 +
 1 file changed, 1 insertion(+)
linux-user/syscall.c +1 -0
index f55cdebee5..c653897d32 100644
@@ -8567,6 +8567,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
             TaskState *ts = cpu->opaque;
 
             object_property_set_bool(OBJECT(cpu), "realized", false, NULL);
+            object_unparent(OBJECT(cpu));
             object_unref(OBJECT(cpu));
             /*
              * At this point the CPU should be unrealized and removed
Signature · 1 line
2.32.1 (Apple Git-133)