M Joonas Pihlaja wrote:
Hi list,
I ran into a problem where a program I'm working on was
segfaulting when calling apr_hash_set() due to memory exhaustion.
So I was going to ask if we can have a version of apr_hash_set()
which could return a status code if it fails to add a value to a
hash. Having a closer look at the source to APR, though, I
realised that almost none of the memory allocation calls inside
APR itself are checked for a NULL return value[1].
The thing is, there are 208 calls to apr_palloc() and 133 to
apr_pcalloc() in the source[2], so it would be quite a large job
to fix all of them. On the up side, of all the cases I did look
at, they all seemed to be of the sort where it would be fairly
easy to add the extra checks to make them fail with APR_ENOMEM.
However, I fear the ripple effect
No kidding :-) If your app has exhausted memory, your reduced to
playing a never ending game of 'whack-a-mole' by attempting to tolerate
all of the ensuing
'bad stuff' that happens. The only OS that I am personally acquainted
with that has a robust designed-in model for dealing with low/no memory
conditions is IBM's zOS. I don't see us ever adding null pointer checks
to apr_palloc/apr_pcalloc returns.
Bill
Bill