[olpc-software] graceful handling of out-of-memory conditions
Alan Cox
alan at redhat.com
Tue Mar 28 10:29:36 UTC 2006
On Tue, Mar 28, 2006 at 01:11:09PM +1000, Martin Sevior wrote:
> Is it possible to provide a signal to a process upon receiving a an Out
> Of Memory rather than just returning a NULL pointer? While returning
The C standard is pretty clear. Handle malloc failure yourself. If you
want a signal from it then wrap malloc and do it yourself. A simple
if(foo == NULL) raise(SIGBLAH)
or in C++ throw an exception.
> NULL pointers will almost certainly cause AbiWord to segfault it would
> nicer to know that the segfault was actually an OOM event rather than a
Thats worrying. So Abiword handles untrusted documents but doesn't do NULL
pointer checks which on some machines lets you scribble on low memory pages
and build exploits.
I hope thats not what you are implying.
> delete classes (to release memory) and to give an appropriate document
> name, if the latter it make more sense to dump the document as quickly
> as possible.
Very hard from a signal handler because you may only use signal safe library
functions.
Alan
More information about the olpc-software
mailing list