Re: Handling out-of-memory
Nick Gorham <[email protected]>
| Newsgroups | gmane.comp.db.unixodbc.devel |
|---|---|
| Message-ID | <[email protected]> |
On 28/02/13 08:04, Heikki Linnakangas wrote: > Hi, > > 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. -- Nick _______________________________________________ unixODBC-dev mailing list [email protected] http://mailman.unixodbc.org/mailman/listinfo/unixodbc-dev