From nobody Tue Nov 18 07:42:01 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608072289; cv=none; d=zohomail.com; s=zohoarc; b=FjplQGS8xwBfQzBoEQefhEGFwAKmHr6YU+ZIfsG590zVERiP+Wuo5rpmy63qQ2HN3eUhSXF0gBc7f9MMaW1nyVQ8iCPW5ySWwK+pwq2XIgd+pMTYyV38y2q97fLiGNApRiZmd6v6DJ1PezZUxQDSN3tpa1RCZc++r8lQtjWQwkg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608072289; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WRK3ASZJ9AJJN/7E7ETacVX5syK9T+YiSHqFgmKQQ2w=; b=A8JhNgL8EQLvfFf6X0IERUcojHFCBCBKd6OOiil5jd+Cac5di3aGUcnlcNvvXWOjM/iLYRA0+B4CEqbH4fKMOulgznAP+miLYzSdJ+ehzQw60JO2eGcF0P+wMyBMZNKcfaJv9c4DR0EGxNU9K41ha4cjnK+oWAc0cR7xL1nw7n0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1608072289759334.35701408493185; Tue, 15 Dec 2020 14:44:49 -0800 (PST) Received: from localhost ([::1]:58998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpJ3o-00014L-Ks for importer@patchew.org; Tue, 15 Dec 2020 17:44:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35188) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpJ1E-0007Qy-8Y for qemu-devel@nongnu.org; Tue, 15 Dec 2020 17:42:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34812) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kpJ0x-00073B-Gk for qemu-devel@nongnu.org; Tue, 15 Dec 2020 17:42:07 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-525-Hh5a_etnNAiknweNXFwPBg-1; Tue, 15 Dec 2020 17:41:49 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2C5EA107ACF5; Tue, 15 Dec 2020 22:41:48 +0000 (UTC) Received: from localhost (ovpn-115-226.rdu2.redhat.com [10.10.115.226]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD68C704DA; Tue, 15 Dec 2020 22:41:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608072110; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WRK3ASZJ9AJJN/7E7ETacVX5syK9T+YiSHqFgmKQQ2w=; b=K5pOD7zIlPinFihl/M2e42DLGJHHL3NxSwsyb6aTQqOU60pNmOjuNigkXhz9wk8LlLtIwz IJY6j8C+ARkGzBSa+8yUD51YX9dksmsAyHeh5vPSLtElygvp1TsETt+qpqxUU2bp6ZbVWc ffGVEdHZ2a+UM2y1X//MYeDG82raugk= X-MC-Unique: Hh5a_etnNAiknweNXFwPBg-1 From: Eduardo Habkost To: Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-devel@nongnu.org Subject: [PATCH 2/2] qom: Assert that objects being destroyed have no parent Date: Tue, 15 Dec 2020 17:41:33 -0500 Message-Id: <20201215224133.3545901-3-ehabkost@redhat.com> In-Reply-To: <20201215224133.3545901-1-ehabkost@redhat.com> References: <20201215224133.3545901-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Alex Benn=C3=A9e --- qom/object.c | 1 + 1 file changed, 1 insertion(+) diff --git a/qom/object.c b/qom/object.c index f2ae6e6b2a..5cfed6d7c6 100644 --- a/qom/object.c +++ b/qom/object.c @@ -685,6 +685,7 @@ static void object_finalize(void *data) object_deinit(obj, ti); =20 g_assert(obj->ref =3D=3D 0); + g_assert(obj->parent =3D=3D NULL); if (obj->free) { obj->free(obj); } --=20 2.28.0