summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEduardo Habkost2020-12-15 23:41:33 +0100
committerPaolo Bonzini2021-01-02 21:03:09 +0100
commit63f957ac96eba545ef60abebfc6741d06fd99ade (patch)
tree3edf4b22984ad54d61eafe678c994045d606d72b
parenttest-char: Destroy chardev correctly at char_file_test_internal() (diff)
downloadqemu-63f957ac96eba545ef60abebfc6741d06fd99ade.tar.gz
qemu-63f957ac96eba545ef60abebfc6741d06fd99ade.tar.xz
qemu-63f957ac96eba545ef60abebfc6741d06fd99ade.zip
qom: Assert that objects being destroyed have no parent
QOM reference counting bugs are often hard to detect, but there's one kind of bug that's easier: if we are freeing an object but is still attached to a parent, it means the reference count is wrong (because the parent always hold a reference to their children). Add an assertion to make sure we detect those cases. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20201215224133.3545901-3-ehabkost@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--qom/object.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/qom/object.c b/qom/object.c
index 5cd43fe366..2fa0119647 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -685,6 +685,7 @@ static void object_finalize(void *data)
object_deinit(obj, ti);
g_assert(obj->ref == 0);
+ g_assert(obj->parent == NULL);
if (obj->free) {
obj->free(obj);
}