Обсуждение: Memory leak in formatting.c

Поиск
Список
Период
Сортировка

Memory leak in formatting.c

От
Konstantin Knizhnik
Дата:
Memory leak in formatting.c in case of using ICU.
Proposed trivial fix is attached.

-- 
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company


Вложения

Re: Memory leak in formatting.c

От
Michael Paquier
Дата:
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

Вложения