From: Michael Paquier <michael@paquier.xyz>
To: Konstantin Knizhnik <k.knizhnik@postgrespro.ru>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Memory leak in formatting.c
Date: Tue, 3 Sep 2019 12:33:10 +0900
Message-ID: <20190903033310.GC3765@paquier.xyz> (raw)
In-Reply-To: <94c0ad0a-cbc2-e4a3-7829-2bdeaf9146db@postgrespro.ru>
References: <94c0ad0a-cbc2-e4a3-7829-2bdeaf9146db@postgrespro.ru>
On Mon, Sep 02, 2019 at 07:52:30PM +0300, Konstantin Knizhnik wrote:
> Memory leak in formatting.c in case of using ICU.
> Proposed trivial fix is attached.
Right. Those three code paths can be triggered with an ICU
collation. I can see for example that patterns like the following one
consume more memory unpatched:
create collation german_phonebook
(provider = icu, locale = 'de-u-co-phonebk');
create table german_phones (number text collate german_phonebook);
insert into german_phones
select repeat('AB', 1000) || repeat('CD', 1000)
from generate_series(1,1000000);
select count(lower(number))
from german_phones, generate_series(1,10000000);
valgrind does not complain in this scenario. Anyway, we cannot assume
that the callers of str_tolower & co are able to do a correct cleanup
of the memory context where the allocation happened, so I have applied
your patch and back-patched down to 10 where the issue has been
introduced. Thanks, Konstantin!
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: michael@paquier.xyz, k.knizhnik@postgrespro.ru
Subject: Re: Memory leak in formatting.c
In-Reply-To: <20190903033310.GC3765@paquier.xyz>
References: <94c0ad0a-cbc2-e4a3-7829-2bdeaf9146db@postgrespro.ru> <20190903033310.GC3765@paquier.xyz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox