From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A669FC4361B for ; Wed, 16 Dec 2020 17:15:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 223FF22D02 for ; Wed, 16 Dec 2020 17:15:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 223FF22D02 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpaOa-0008Kf-Lb for qemu-devel@archiver.kernel.org; Wed, 16 Dec 2020 12:15:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpa3T-0006FD-KA for qemu-devel@nongnu.org; Wed, 16 Dec 2020 11:53:35 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:40344) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kpa3R-00031M-Qe for qemu-devel@nongnu.org; Wed, 16 Dec 2020 11:53:35 -0500 Received: by mail-wr1-x436.google.com with SMTP id 91so23852386wrj.7 for ; Wed, 16 Dec 2020 08:53:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=references:user-agent:from:to:cc:subject:date:in-reply-to :message-id:mime-version:content-transfer-encoding; bh=6E7kkE4XaLghtOuxtTk1YrrTQaGAigk4ExP60cxtTK4=; b=P5/KIkBfOdfEACg6fE9HgpkaIWoHlvOsohqoAkTE3pL+AGJ3iJ44ewuSonDQ+4lrWh TFxuKwfr4LDuJFD1iy9O3qfmjXA77KrKY9XolRNNV0AWr/KIXzWd43KV564zrcusJMnU YGx5hTJk6yMIYxSVWNOJPH6VWLa7MAENTfkxT5IU42hDLVz7I3Sksc3Jb2mTi5kyLW1P bycnWWOBUCF3qbByxy7hsIOZuLAYqr2nr0DkqfYUoXBTL6DD/csfQvRYUwdaa75J/s3X /Pvvx8Lcq/BlHctC+yzo9wEsJv0J4OJSGG0lWKew0dTZ+K7EOvVmPqQHNv44lLXx0nH8 2iMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject:date :in-reply-to:message-id:mime-version:content-transfer-encoding; bh=6E7kkE4XaLghtOuxtTk1YrrTQaGAigk4ExP60cxtTK4=; b=R1qT0KAfSOAHhWDTd7KF5nEl96C//TS8TRml04J6qCKjw0i6txaA1zL0/MJM89s522 mAPyytVgvc5BhHdeLjOjEfLKtrQDm+3cUAzO4gr92Vb2GwkFju8yxtl1ZAU0TG4xm7eN LFJGb/le7T74nRgvqCGoBkzzVnhuHaEp3Kg+GgzPpPyczYzqTiv99t1K2wKRboIXuHtR Y0KjJ7JpodHkz+nIqYFb4pyw378dsZmPWbbWXmzIulq/pKCmxi40oiRqClRs5xhEMTv7 5ClmiC4aF08N7t92bSTmi8Z0PzbfH+njB5M/juxphJ89o8dfdyXiMbx0+er0hTx7BA1y g2PQ== X-Gm-Message-State: AOAM531xOgyuNHEYE13+3cUdLtMycTSqArazsPg5WkatAeR1fBndNM0c 6tKLqy+7O4yVuiY/de/yNFDr3A== X-Google-Smtp-Source: ABdhPJyO71ko3itwYYwgXa1EgNagffnQ6nEBLJS93JpAoH7AOXiKX/pLp+vz+E5O0aIBlSbFHrnRbQ== X-Received: by 2002:a5d:6749:: with SMTP id l9mr39592328wrw.395.1608137611168; Wed, 16 Dec 2020 08:53:31 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id h184sm3367938wmh.23.2020.12.16.08.53.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Dec 2020 08:53:29 -0800 (PST) Received: from zen (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 37AC11FF7E; Wed, 16 Dec 2020 16:53:29 +0000 (GMT) References: <20201215224133.3545901-1-ehabkost@redhat.com> <20201215224133.3545901-3-ehabkost@redhat.com> User-agent: mu4e 1.5.7; emacs 28.0.50 From: Alex =?utf-8?Q?Benn=C3=A9e?= To: Eduardo Habkost Subject: Re: [PATCH 2/2] qom: Assert that objects being destroyed have no parent Date: Wed, 16 Dec 2020 16:52:27 +0000 In-reply-to: <20201215224133.3545901-3-ehabkost@redhat.com> Message-ID: <87lfdxsnee.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x436.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: qemu-devel@nongnu.org, Paolo Bonzini , =?utf-8?Q?Daniel_P=2E_Berrang=C3=A9?= , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Eduardo Habkost writes: > 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 I'm happy with an assert and crash early approach if the alternative it scratching your head when things crash in weird ways. I'll of course defer to the maintainer but from me: 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=20 > g_assert(obj->ref =3D=3D 0); > + g_assert(obj->parent =3D=3D NULL); > if (obj->free) { > obj->free(obj); > } --=20 Alex Benn=C3=A9e