From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35841) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxOAV-0001U8-Iv for qemu-devel@nongnu.org; Fri, 13 Nov 2015 18:54:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZxOAS-0003YW-Cv for qemu-devel@nongnu.org; Fri, 13 Nov 2015 18:54:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51824) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxOAS-0003Xv-7X for qemu-devel@nongnu.org; Fri, 13 Nov 2015 18:54:08 -0500 References: <1447224690-9743-1-git-send-email-eblake@redhat.com> <1447224690-9743-23-git-send-email-eblake@redhat.com> From: Eric Blake Message-ID: <56467819.4070608@redhat.com> Date: Fri, 13 Nov 2015 16:54:01 -0700 MIME-Version: 1.0 In-Reply-To: <1447224690-9743-23-git-send-email-eblake@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="fPCwJtXuKIXgxmJvdVrVaNvqlrXPwOo4T" Subject: Re: [Qemu-devel] [PATCH v11 22/28] qapi: Simplify visiting of alternate types List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: armbru@redhat.com, Michael Roth This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --fPCwJtXuKIXgxmJvdVrVaNvqlrXPwOo4T Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/10/2015 11:51 PM, Eric Blake wrote: > Previously, working with alternates required two lookup arrays > and some indirection: for type Foo, we created Foo_qtypes[] > which maps each qtype to a value of the generated FooKind enum, > then look up that value in FooKind_lookup[] like we do for other > union types. >=20 > This has a couple of subtle bugs. First, the generator was > creating a call with a parameter '(int *) &(*obj)->type' where > type is an enum type; this is unsafe if the compiler chooses > to store the enum type in a different size than int, where > assigning through the wrong size pointer can corrupt data or > cause a SIGBUS. Yuck - we still have this bug for enums: > void visit_type_OnOffAuto(Visitor *v, OnOffAuto *obj, const char *name,= Error **errp) > { > visit_type_enum(v, (int *)obj, OnOffAuto_lookup, "OnOffAuto", name, err= p); > } I guess I just added more work to my plate. But at the same time, no one has complained of the (int*)Enum causing SIGBUS on any of our platforms for either enums or alternates, so while we are doing gross things, I don't think we have to rush a fix into 2.5 for this particular bug. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --fPCwJtXuKIXgxmJvdVrVaNvqlrXPwOo4T 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/ iQEcBAEBCAAGBQJWRngZAAoJEKeha0olJ0NqYFMH/iuf1Zlh0zzVwsONkz5mfPfk ePd0i8ZGpbY770u4k9n/4AptA5VV5K+PTurfsqbnYcedghEgbok7Wz36mKAvcmnE ttuwh/+4sdbfhws9TKb0k+sLbmGckkd48UoT4CcOghrM5mDrMa2R1Lr5dYvUXCHq BQew9upsC4Pm5iiKF6UThu+Gwe/QPAkkTRZz2nsPKum0Zt97CoWMf5ZqiLr0IDtj JQ00au4rAFqDLXLL33usRSJZE3LiI/b4VYMpsSnW45UGjGQEuwHzAUnXQaXA/ESB TbmYRktgnntccAGExYAD+aSydy7fMw2tvSNbhSPZLXkUBixFEqt9N7EETHuwRbw= =STCw -----END PGP SIGNATURE----- --fPCwJtXuKIXgxmJvdVrVaNvqlrXPwOo4T--