[unixODBC-dev] Handling out-of-memory
nick at lurcher.org
Thu Feb 28 08:19:10 GMT 2013
On 28/02/13 08:04, Heikki Linnakangas wrote:
> While working on the PostgreSQL driver, I bumped into two little bugs
> in handling out-of-memory situation. Patch attached. It's probably
> self-evident from the patch what the bugs are, but I'll explain anyway:
> 1. In __post_internal_error_ex, check for NULL return from malloc, and
> avoid some unnecessary allocations so that we don't need to handle the
> case that they fail. (In my test case, the reason that
> __post_internal_error_ex got called in the first place was that
> dlopen() failed with Out-of-Memory while loading the driver, so it's
> not surprising that those allocations failed too)
> 2. In __alloc_desc, there is a check for calloc returning NULL, but
> some of the initialization code was misplaced, and was being called on
> the NULL pointer anyway.
> There are a lot more places where we don't check for malloc returning
> NULL, but fixing those two made my test case work. In the test case, I
> opened a large number of connections, and to induce the OOM condition,
> I ran it with a small "ulimit -v".
> - Heikki
Thanks, I will commit those tonight.
More information about the unixODBC-dev