From patchwork Thu Feb 4 20:13:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 44553 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 62DE1B7D4F for ; Fri, 5 Feb 2010 08:11:04 +1100 (EST) Received: from localhost ([127.0.0.1]:53059 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nd8ya-0003Ml-5O for incoming@patchwork.ozlabs.org; Thu, 04 Feb 2010 16:11:00 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nd8xm-0003DW-3n for qemu-devel@nongnu.org; Thu, 04 Feb 2010 16:10:10 -0500 Received: from [199.232.76.173] (port=55354 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nd8xl-0003D2-MF for qemu-devel@nongnu.org; Thu, 04 Feb 2010 16:10:09 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nd8xj-0002m5-T6 for qemu-devel@nongnu.org; Thu, 04 Feb 2010 16:10:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32622) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nd8xj-0002lz-HR for qemu-devel@nongnu.org; Thu, 04 Feb 2010 16:10:07 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o14KFQFv025739 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 4 Feb 2010 15:15:26 -0500 Received: from localhost (vpn-9-202.rdu.redhat.com [10.11.9.202]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o14KFO20022405 for ; Thu, 4 Feb 2010 15:15:25 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Thu, 4 Feb 2010 18:13:15 -0200 Message-Id: <1265314396-6583-4-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1265314396-6583-1-git-send-email-lcapitulino@redhat.com> References: <1265314396-6583-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 3/4] QError: Don't abort on multiple faults X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Ideally, Monitor code should report an error only once and return the error information up the call chain. To assure that this happens as expected and that no error is lost, we have an assert() in qemu_error_internal(). However, we still have not fully converted handlers using monitor_printf() to report errors. As there can be multiple monitor_printf() calls on an error, the assertion is easily triggered when debugging is enabled; and we will get a memory leak if it's not. The solution to this problem is to allow multiple faults by only reporting the first one, and to release the additional error objects. A better mechanism to report multiple errors to programmers is underway. Signed-off-by: Luiz Capitulino --- monitor.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/monitor.c b/monitor.c index cb7eb65..c8b63aa 100644 --- a/monitor.c +++ b/monitor.c @@ -4625,8 +4625,13 @@ void qemu_error_internal(const char *file, int linenr, const char *func, QDECREF(qerror); break; case ERR_SINK_MONITOR: - assert(qemu_error_sink->mon->error == NULL); - qemu_error_sink->mon->error = qerror; + /* report only the first error */ + if (!qemu_error_sink->mon->error) { + qemu_error_sink->mon->error = qerror; + } else { + /* XXX: warn the programmer */ + QDECREF(qerror); + } break; } }