[unixODBC-dev] Handling out-of-memory
hlinnakangas at vmware.com
Thu Feb 28 08:04:14 GMT 2013
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".
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 9228 bytes
Desc: not available
More information about the unixODBC-dev