apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Graham Leggett <minf...@sharp.fm>
Subject Re: apr_hash_set allocation failure behavior
Date Wed, 17 Mar 2010 22:39:18 GMT
On 18 Mar 2010, at 12:18 AM, Ivan Novick wrote:

> I am doing some testing with APR version 1.2.12
>
> When adding to a hash table using apr_hash_set ... If memory can not  
> be
> allocated what is the expected behavior?
>
> I am seeing apr_hash_set calls expand_array.
>
> expand_array core dumps if memory can not be allocated.
>
> Is this expected?  Is there a way to get an error code for a failed  
> insert
> to a table rather than a coredump?

This is definitely wrong, APR should return APR_ENOMEM if memory  
cannot be allocated.

More specifically, the APR pools code gives the caller (you) the  
choice of behaviour when the memory allocation fails. You can choose  
to have APR call a function of your choice, or you can choose APR to  
return APR_ENOMEM.

httpd chooses to call a function that terminates the server child when  
out of memory, and as a result httpd makes no attempt to cater for out  
of memory conditions, but other callers of APR don't have to, and APR  
itself should definitely respect APR_ENOMEM.

Regards,
Graham
--


Mime
View raw message