From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaVRm-0004Mo-5O for qemu-devel@nongnu.org; Fri, 11 Sep 2015 17:01:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaVRi-0000Aw-5f for qemu-devel@nongnu.org; Fri, 11 Sep 2015 17:01:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57447) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaVRh-0000AM-T2 for qemu-devel@nongnu.org; Fri, 11 Sep 2015 17:01:22 -0400 References: <1441999089-28960-1-git-send-email-armbru@redhat.com> <1441999089-28960-21-git-send-email-armbru@redhat.com> <55F33D06.1090103@redhat.com> From: Eric Blake Message-ID: <55F3411B.5070905@redhat.com> Date: Fri, 11 Sep 2015 15:01:15 -0600 MIME-Version: 1.0 In-Reply-To: <55F33D06.1090103@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="HVaKP4UuItX2ufDd2DqTcLfLfowhOoWVF" Subject: Re: [Qemu-devel] [PATCH v6 20/26] qapi: Fix output visitor to return qnull() instead of NULL List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , qemu-devel@nongnu.org Cc: mdroth@linux.vnet.ibm.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --HVaKP4UuItX2ufDd2DqTcLfLfowhOoWVF Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/11/2015 02:43 PM, Eric Blake wrote: >> +++ b/tests/test-qmp-output-visitor.c >> @@ -485,7 +485,7 @@ static void test_visitor_out_empty(TestOutputVisit= orData *data, >> QObject *arg; >> =20 >> arg =3D qmp_output_get_qobject(data->qov); >> - g_assert(!arg); >> + g_assert(qobject_type(arg) =3D=3D QTYPE_QNULL); >> } >=20 > Missing > qobject_decref(arg); >=20 > Ultimately, the global qnull_ starts life with refcnt 1, and after this= > test should be back to 1. But it is coming back as 3, so even with a > qobject_decref, that would get it back down to 2. So we are leaking a > reference to qnull somewhere. >=20 > I'm still investigating, and may be able to find the patch Squash this in, and you can have: Reviewed-by: Eric Blake diff --git i/qapi/qmp-output-visitor.c w/qapi/qmp-output-visitor.c index 2d6083e..b96849e 100644 --- i/qapi/qmp-output-visitor.c +++ w/qapi/qmp-output-visitor.c @@ -66,11 +66,7 @@ static QObject *qmp_output_first(QmpOutputVisitor *qov= ) { QStackEntry *e =3D QTAILQ_LAST(&qov->stack, QStack); - if (!e) { - return qnull(); - } - - return e->value; + return e ? e->value : NULL; } static QObject *qmp_output_last(QmpOutputVisitor *qov) @@ -190,6 +186,8 @@ QObject *qmp_output_get_qobject(QmpOutputVisitor *qov= ) QObject *obj =3D qmp_output_first(qov); if (obj) { qobject_incref(obj); + } else { + obj =3D qnull(); } return obj; } diff --git i/tests/test-qmp-output-visitor.c w/tests/test-qmp-output-visitor.c index 256bffd..8bd48f4 100644 --- i/tests/test-qmp-output-visitor.c +++ w/tests/test-qmp-output-visitor.c @@ -486,6 +486,9 @@ static void test_visitor_out_empty(TestOutputVisitorData *data, arg =3D qmp_output_get_qobject(data->qov); g_assert(qobject_type(arg) =3D=3D QTYPE_QNULL); + /* Check that qnull reference counting is sane */ + g_assert(arg->refcnt =3D=3D 2); + qobject_decref(arg); } static void init_native_list(UserDefNativeListUnion *cvalue) --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --HVaKP4UuItX2ufDd2DqTcLfLfowhOoWVF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV80EbAAoJEKeha0olJ0NqORMH/iVJH4tUp9KL6n+5/G/cZVeF wOcyv4RdvRMgpp2tC8vQgVVVw5irnrArlwvi0g6+Nz+6QsoMcnspzq7r/GhsCO++ jgQMG1+kEDyOGtetc5j0OzjKEFWHnJX7LmxvYXexBiQKLmhKKoMpJGSXzFlbD+An Rk/08FZrCF+Pc/bFcW7bzWILsdQ76tnq8F35ERccHLRA9LdJvbpbuuro6O8HhjwH 0dQNKQ+I+89EL/XfJn+DKFE9IqAY0EUI5eaLb6E9h+K2jQdWMJ3XssX26+8qtrY2 m6D1eQqGsCgEMmt2p47OZ//E7r2shYw0p9A4stAkMFIZs1ZpwqvhqWvxyvdtcDU= =EJgR -----END PGP SIGNATURE----- --HVaKP4UuItX2ufDd2DqTcLfLfowhOoWVF--