From patchwork Mon Feb 8 19:01:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 44814 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 24C74B7CEF for ; Tue, 9 Feb 2010 06:10:35 +1100 (EST) Received: from localhost ([127.0.0.1]:35184 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NeYvd-0001q4-Nj for incoming@patchwork.ozlabs.org; Mon, 08 Feb 2010 14:05:49 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NeYrj-0000zM-52 for qemu-devel@nongnu.org; Mon, 08 Feb 2010 14:01:47 -0500 Received: from [199.232.76.173] (port=33462 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NeYri-0000yx-5H for qemu-devel@nongnu.org; Mon, 08 Feb 2010 14:01:46 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NeYrg-0003AK-JF for qemu-devel@nongnu.org; Mon, 08 Feb 2010 14:01:45 -0500 Received: from mx20.gnu.org ([199.232.41.8]:4965) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NeYrg-00039V-7C for qemu-devel@nongnu.org; Mon, 08 Feb 2010 14:01:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NeYrf-0005dG-CS for qemu-devel@nongnu.org; Mon, 08 Feb 2010 14:01:43 -0500 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o18J1g6H018445 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 8 Feb 2010 14:01:42 -0500 Received: from localhost (vpn-8-125.rdu.redhat.com [10.11.8.125]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o18J1ftG014246 for ; Mon, 8 Feb 2010 14:01:41 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Mon, 8 Feb 2010 17:01:29 -0200 Message-Id: <1265655690-6628-4-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1265655690-6628-1-git-send-email-lcapitulino@redhat.com> References: <1265655690-6628-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by mx20.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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; } }