From patchwork Tue Feb 19 04:02:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 221610 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6D5622C0085 for ; Tue, 19 Feb 2013 15:03:02 +1100 (EST) Received: from localhost ([::1]:36339 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7eQ0-0004xl-Kp for incoming@patchwork.ozlabs.org; Mon, 18 Feb 2013 23:03:00 -0500 Received: from eggs.gnu.org ([208.118.235.92]:50793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7ePj-0004VL-O9 for qemu-devel@nongnu.org; Mon, 18 Feb 2013 23:02:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U7ePg-0006jV-Rm for qemu-devel@nongnu.org; Mon, 18 Feb 2013 23:02:43 -0500 Received: from mail-da0-f46.google.com ([209.85.210.46]:61774) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7ePg-0006jQ-Mh for qemu-devel@nongnu.org; Mon, 18 Feb 2013 23:02:40 -0500 Received: by mail-da0-f46.google.com with SMTP id p5so2735592dak.19 for ; Mon, 18 Feb 2013 20:02:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:in-reply-to:references:x-gm-message-state; bh=DQQQ2nbPcrCZ57yJbWBnUbVOXMyL6WwikVzNWydZyEY=; b=RKmJyW3oKGB1RkcDmnKSm4kDdpHBGKjUuN0NsJECuqWpCWCcnJpubusJRoQWZVDQqP 4ypZKsMN/KEI+flDXepjUQVizg/589kzWTiAeHAEz1SyRkJks7PzXBHMdgnGOr7+0RXB xVGvMXrUwQTQzdxkFrz+J8ZeyHFs/D3JnPzTJu8hENVDs74EA45U6Fhb7bzNcMZE7wTl DatWDXyuTcg8uYdtR7ZSFOIsCxMxLS1J96uW0iD6nDgempepPqhbm7xkhGQB59cG4ciI YVrT+WPjUcssJ4+dMGQ9/izuOvH00U+OvDftThBoWVZDw2Y40AqN7J1CKMsBucaN6jKh xqXQ== X-Received: by 10.68.220.133 with SMTP id pw5mr9352746pbc.126.1361246559944; Mon, 18 Feb 2013 20:02:39 -0800 (PST) Received: from localhost ([1.140.68.106]) by mx.google.com with ESMTPS id rn14sm16515370pbb.33.2013.02.18.20.02.36 (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Mon, 18 Feb 2013 20:02:38 -0800 (PST) From: Peter Crosthwaite To: qemu-devel@nongnu.org Date: Tue, 19 Feb 2013 14:02:09 +1000 Message-Id: <1f58d2b629d82865dbb2fd5ba8445854049c4382.1361246206.git.peter.crosthwaite@xilinx.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQm39X94SsT89HTDI+GzK5lr3DRzgqt1UfNrjzNzpohepusBV33B5IpG5tbRnWG58n1hMWkq X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.210.46 Cc: pbonzini@redhat.com, aliguori@us.ibm.com, Peter Crosthwaite Subject: [Qemu-devel] [PATCH v2 1/2] qom/object.c: Reset interface list on inheritance X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The QOM framework will attempt the recreate a classes interface list from scratch for each class. This means that a child class should zero out the list of interfaces when cloned from the parent class. Currently the list is memcpy()d from the parent to the child. As the interface list is just a pointer to a list, this means the parent and child will share the same list of interfaces. When the child inits, it will append its own interfaces to the parents list. This is incorrect as the parent should not pick up its childs interfaces. This actually causes an infinite loop at class init time, as the child will iterate through the parent interface list adding each itf to its own list(in type_initialize()). As the list is (erroneously) shared, the new interface instances for the child are appended to the parent, and the iterator never hits the tail and loops forever. Signed-off-by: Peter Crosthwaite Reviewed-by: Paolo Bonzini --- qom/object.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/qom/object.c b/qom/object.c index 563e45b..4b72a64 100644 --- a/qom/object.c +++ b/qom/object.c @@ -245,6 +245,7 @@ static void type_initialize(TypeImpl *ti) g_assert(parent->class_size <= ti->class_size); memcpy(ti->class, parent->class, parent->class_size); + ti->class->interfaces = NULL; for (e = parent->class->interfaces; e; e = e->next) { ObjectClass *iface = e->data;