On 02/10/2012 07:41 AM, Daniel P. Berrange wrote: >> @@ -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.
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. -- Eric Blake ebl...@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature