Received: from eggs.gnu.org ([2001:4830:134:3::10]:52063) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwSU2-00075N-MT for qemu-devel@nongnu.org; Tue, 18 Oct 2016 07:23:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwSTx-0000ZT-Pp for qemu-devel@nongnu.org; Tue, 18 Oct 2016 07:23:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35658) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bwSTx-0000YV-Hh for qemu-devel@nongnu.org; Tue, 18 Oct 2016 07:22:57 -0400 From: Pino Toscano Date: Tue, 18 Oct 2016 13:22:49 +0200 Message-ID: <3321636.HNiH4nMqTU@thyrus.usersys.redhat.com> In-Reply-To: References: <1476782267-2602-1-git-send-email-ptoscano@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1981243.ZezCpnOHqz"; micalg="pgp-sha256"; protocol="application/pgp-signature" Subject: Re: [Qemu-devel] [PATCH] qapi: fix memory leak in QmpOutputVisitor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org, armbru@redhat.com, mdroth@linux.vnet.ibm.com --nextPart1981243.ZezCpnOHqz Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" On Tuesday, 18 October 2016 06:13:30 CEST Eric Blake wrote: > On 10/18/2016 04:17 AM, Pino Toscano wrote: > > qmp_output_start_struct() and qmp_output_start_list() create a new > > QObject (QDict, QList) and push it to the stack of the QmpOutputVisitor, > > where it is saved as 'value'. When freeing the iterator in > > qmp_output_free(), these values are never freed properly. > > Do any of the tests (perhaps run under valgrind) show this leak? If not, > maybe we should enhance their coverage. Running a simple `qemu-img info file.qcow2` under valgrind was enough for me to show the leak. In this case, another simple fix is needed to fully fix the leak: http://lists.nongnu.org/archive/html/qemu-devel/2016-10/msg04023.html (Yes, I just saw your ACK on this, Eric, just leaving it here for reference.) > > > > The simple solution is to qobject_decref() them. > > --- > > qapi/qmp-output-visitor.c | 1 + > > 1 file changed, 1 insertion(+) > > Reviewed-by: Eric Blake > > > > > diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c > > index 9e3b67c..eedf256 100644 > > --- a/qapi/qmp-output-visitor.c > > +++ b/qapi/qmp-output-visitor.c > > @@ -220,6 +220,7 @@ static void qmp_output_free(Visitor *v) > > while (!QSLIST_EMPTY(&qov->stack)) { > > e = QSLIST_FIRST(&qov->stack); > > QSLIST_REMOVE_HEAD(&qov->stack, node); > > + qobject_decref(e->value); > > g_free(e); > > } > > > > > > -- Pino Toscano --nextPart1981243.ZezCpnOHqz Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJYBgYJAAoJEMPRTC2YZDfN26oP/iBz2DCC9ggHuia2JXZqeeUk HnqaFWJ9zB5dVxkiXk8GiojXFTzldqNGw3JffhveYG4jGroiN2q8nLHh3nWLT1G0 0EPF+zkpAq8oiLM1qOMzpFT3ARXE+U7qSli37iblR/CJm9GD+E9iutz+GpWE+EvU RBaiHTyjsUslCd2+8rE1uFYlpv5j5YAklHLBwB/r/0hmQUtGluBlSyTn1cI0dmod 69gNe/R/NsxH1s5zTEPnZj9GzRqRzJmqVs5H53nAsa7GqZgtAhs4n851dRjMHa8j nNniGCzEYbrkUlHBqSK9rVvuqRmdZBI5Lq23cXvoY4sYq2cwZdgLC0kCKVVIN0Rf lDe+gPgCz08Q5XA/eGciuv8gznRVEQEvJ1ZhrsBhYuN7RxG5vvaA7VCTFKNiLofm WDL4eCb84YvjXzM+HyJx2VADvyklZ3SxXVgGd/Ec4BqLDlizTZi12LH88VOSYVhs vAuk/7/4XhdQ28JJ2C7Hr0GZR0MsDtL4otB1qYuNk69cj1SjSf2QdxF31sdoHpkU WR34Z/ht/ZitjRY27U0UL4/iiLA5L3GD3U3GTdQON6z5OxT3cAKo4tFoZdD18fj+ jyIw+8OfwOJIrlxOqUzzJLtnLaC4GxAbGSZrGdOU3kLc6OxnmWQ1ggpZjPSwBAaL lmQY8Er5h1JJr9Y/8chW =n7Ng -----END PGP SIGNATURE----- --nextPart1981243.ZezCpnOHqz--