From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:43715) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvvJa-00031c-0H for qemu-devel@nongnu.org; Fri, 10 Feb 2012 13:35:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RvvJU-00041w-2d for qemu-devel@nongnu.org; Fri, 10 Feb 2012 13:35:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38698) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvvJT-00041X-Ro for qemu-devel@nongnu.org; Fri, 10 Feb 2012 13:35:16 -0500 Message-ID: <4F35635F.7070107@redhat.com> Date: Fri, 10 Feb 2012 11:35:11 -0700 From: Eric Blake MIME-Version: 1.0 References: <1328884453-1067-1-git-send-email-zwu.kernel@gmail.com> <20120210144115.GI2914@redhat.com> In-Reply-To: <20120210144115.GI2914@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigAD24919B54181652B24EED27" Subject: Re: [Qemu-devel] [PATCH] oslib: make error handling more reasonable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: Zhi Yong Wu , Zhi Yong Wu , qemu-devel@nongnu.org, stefanha@linux.vnet.ibm.com This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigAD24919B54181652B24EED27 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 02/10/2012 07:41 AM, Daniel P. Berrange wrote: >> @@ -80,7 +80,7 @@ void *qemu_oom_check(void *ptr) >> { >> if (ptr =3D=3D NULL) { >> fprintf(stderr, "Failed to allocate memory: %s\n", strerror(e= rrno)); >> - abort(); >> + exit(EXIT_FAILURE); >=20 > 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 >=20 > The only option other than abort(), is to use _Exit() which > doesn't try to run cleanup handlers. Correct, but in that case, then you need to fflush(stderr) prior to _Exit(), or else use write() rather than fprintf(), since otherwise your attempt at a nice oom error message is lost. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enigAD24919B54181652B24EED27 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJPNWNfAAoJEKeha0olJ0Nq8oQH+QGutkGZUFI5o822IMrej8Rf vY8Wazi7VpF1v90uJ087NA+dJqIgeJ0PLvdIg68zC5y/v2/aBUtFuQqX99UNTC6z 55Us5jcB8VP0xdWpfbLV6N2H1ND9rMwZn1KAjk+6SpfpFuB2ay+yVna8Ny4wL3as zN4xjLkaFvw00eroFRkGb/hmI1noWv4O7BSJ/BUzOMNqqVr2Re4WYx24ZBSYOaiI I06AUkp9NiinUi6AdIh87z+qd3SaUYSWYv5DIrNG/CvdAazqP3F6hK0Ka35Qc3hs JdXQagogAvLv0RkKHV5F/PTOwq+rOWeerg75zuQO8cSVujWHTDS0kyez3hYLSI4= =n6BR -----END PGP SIGNATURE----- --------------enigAD24919B54181652B24EED27--