From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vns5o-0004cs-8W for qemu-devel@nongnu.org; Tue, 03 Dec 2013 10:41:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vns5j-0000WM-Nq for qemu-devel@nongnu.org; Tue, 03 Dec 2013 10:40:56 -0500 Message-ID: <529DFB7E.5040309@redhat.com> Date: Tue, 03 Dec 2013 16:40:46 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <23ad4a5a9283ffcf4fc384832f369df46db18ef6.1385612379.git.peter.crosthwaite@xilinx.com> In-Reply-To: <23ad4a5a9283ffcf4fc384832f369df46db18ef6.1385612379.git.peter.crosthwaite@xilinx.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH qom v1 1/1] qom/object.c: Split out object and class caches. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Crosthwaite Cc: aliguori@us.ibm.com, qemu-stable@nongnu.org, qemu-devel@nongnu.org, afaerber@suse.de Il 28/11/2013 05:27, Peter Crosthwaite ha scritto: > The object-cast and class-cast caches cannot be shared because class > caching is conditional on the target type not being an interface and > object caching is unconditional. Leads to a bug when a class cast > to an interface follows an object cast to the same interface type: > > FooObject = FOO(obj); > FooClass = FOO_GET_CLASS(obj); > > Where TYPE_FOO is an interface. The first (object) cast will be > successful and cache the casting result (i.e. TYPE_FOO will be cached). > The second (class) cast will then check the shared cast cache > and register a hit. The issue is, when a class cast hits in the cache > it just returns a pointer cast of the input class (i.e. the concrete > class). > > When casting to an interface, the cast itself must return the > interface class, not the concrete class. The implementation of class > cast caching already ensures that the returned cast result is only > a pointer cast before caching. The object cast logic however does > not have this check. > > Resolve by just splitting the object and class caches. > > Signed-off-by: Peter Crosthwaite Cc: qemu-stable@nongnu.org Reviewed-by: Paolo Bonzini