From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:56377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvrfF-0007J3-QA for qemu-devel@nongnu.org; Fri, 10 Feb 2012 09:41:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rvrf9-0000vt-Lp for qemu-devel@nongnu.org; Fri, 10 Feb 2012 09:41:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45312) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rvrf9-0000vp-E0 for qemu-devel@nongnu.org; Fri, 10 Feb 2012 09:41:23 -0500 Date: Fri, 10 Feb 2012 14:41:15 +0000 From: "Daniel P. Berrange" Message-ID: <20120210144115.GI2914@redhat.com> References: <1328884453-1067-1-git-send-email-zwu.kernel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1328884453-1067-1-git-send-email-zwu.kernel@gmail.com> Subject: Re: [Qemu-devel] [PATCH] oslib: make error handling more reasonable Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Zhi Yong Wu Cc: Zhi Yong Wu , qemu-devel@nongnu.org, stefanha@linux.vnet.ibm.com On Fri, Feb 10, 2012 at 10:34:13PM +0800, Zhi Yong Wu wrote: > From: Zhi Yong Wu > > Signed-off-by: Zhi Yong Wu > --- > oslib-posix.c | 4 ++-- > oslib-win32.c | 4 ++-- > 2 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/oslib-posix.c b/oslib-posix.c > index b6a3c7f..f978d56 100644 > --- a/oslib-posix.c > +++ b/oslib-posix.c > @@ -80,7 +80,7 @@ void *qemu_oom_check(void *ptr) > { > if (ptr == NULL) { > fprintf(stderr, "Failed to allocate memory: %s\n", strerror(errno)); > - abort(); > + exit(EXIT_FAILURE); exit() will call any atexit()/on_exit() handlers, as well as trying to flush I/O streams. Any of these actions may require further memory allocations, which will likely fail, or worse cause this code to re-enter itself if an atexit() handler calls qemu_malloc The only option other than abort(), is to use _Exit() which doesn't try to run cleanup handlers. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|