Received: from eggs.gnu.org ([2001:4830:134:3::10]:39864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyKom-0005hN-1q for qemu-devel@nongnu.org; Mon, 16 Nov 2015 09:31:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZyKoh-0001qi-Vj for qemu-devel@nongnu.org; Mon, 16 Nov 2015 09:31:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50830) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyKoh-0001qb-QJ for qemu-devel@nongnu.org; Mon, 16 Nov 2015 09:31:35 -0500 From: Markus Armbruster References: <1447224690-9743-1-git-send-email-eblake@redhat.com> <1447224690-9743-23-git-send-email-eblake@redhat.com> <56467819.4070608@redhat.com> Date: Mon, 16 Nov 2015 15:31:33 +0100 In-Reply-To: <56467819.4070608@redhat.com> (Eric Blake's message of "Fri, 13 Nov 2015 16:54:01 -0700") Message-ID: <87r3jqdni2.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain 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: Eric Blake Cc: qemu-devel@nongnu.org, Michael Roth Eric Blake writes: > 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. >> >> 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, errp); >> } > > 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. If it was a new bug, I'd push for fixing it in 2.5. Since it's ancient, I think we should leave it alone in 2.5.