Re: Improve OOM handling in pg_locale.c

From: Mithun Cy <mithun(dot)cy(at)enterprisedb(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improve OOM handling in pg_locale.c
Date: 2016-11-17 03:24:46
Message-ID: CAD__OujDqK8xmpW6xVM-SDNCP=-hf3Czr-m=o-JZKa=bjbTLgw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Oct 13, 2016 at 1:40 PM, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
wrote:
> I am attaching that to the next CF.

I have tested this patch. Now we error out as OOM instead of crash.
------------------------------------------------
postgres=# SELECT '12.34'::money;
ERROR: out of memory
LINE 1: SELECT '12.34'::money;
------------------------------------------------

One thing which you might need to reconsider is removal of memory leak
comments. There is still a leak if there is an error while encoding in
db_encoding_strdup.
Unless you want to catch those error with an TRY();....CATCH(); and then
free the mem.

- * localeconv()'s results. Note that if we were to fail within this
- * sequence before reaching "CurrentLocaleConvAllocated = true", we could
- * leak some memory --- but not much, so it's not worth agonizing over.

Rest all LGTM.
--
Thanks and Regards
Mithun C Y
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2016-11-17 03:45:52 Re: pg_dump versus rules, once again
Previous Message Kyotaro HORIGUCHI 2016-11-17 03:16:01 Re: Document how to set up TAP tests for Perl 5.8.8