Re: BUG #8461: PostgreSQL 9.3 pg_dump heap corruptions

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: BUG #8461: PostgreSQL 9.3 pg_dump heap corruptions
Дата
Msg-id 20140215040111.GA15047@momjian.us
обсуждение исходный текст
Ответ на Re: BUG #8461: PostgreSQL 9.3 pg_dump heap corruptions  (Benjamin Wassermann <benny@hegne.de>)
Ответы Re: BUG #8461: PostgreSQL 9.3 pg_dump heap corruptions  (Bruce Momjian <bruce@momjian.us>)
Список pgsql-bugs
On Mon, Oct 14, 2013 at 05:31:46AM -0700, Benjamin Wassermann wrote:
> We finally find out why this problem occurs.
>
> PG_dump use some Functions like
> initPQExpBuffer(..)
> from the libpq.dll.
>
> In this function "initPQExpBuffer(...)" are some memory allocated with
> malloc(...).
> (File: "pg_dump.c", line 9366)
>
> After the function is successfully dumped to backup file, there is a
> "free(...)" in Function "dumpFunc" at line 9942 ff.
> ...
>         free(funcsig);
> ...
>
> but the PG_dump.exe cant free memory which is allocated by libpq.dll.
>
> To fix this problem the "libpq.dll" need a new function named
> "deletePQCharPointer()"

Actually, there are many places where Windows binaries free memory
allocated by libpq.  This is possible because of the way we compile
libpq and the binary.  Our PQfreemem() manual page has the details

      It is particularly important that this function, rather than
      free(), be used on Microsoft Windows.  This is because allocating
      memory in a DLL and releasing it in the application works only if
      multithreaded/single-threaded, release/debug, and static/dynamic
      flags are the same for the DLL and the application.  On non-Microsoft
      Windows platforms, this function is the same as the standard library
      function free().

If the free() was not working for you, my guess is that you had
mismatched flags for libpq and pg_dump compiles.

However, you were right that there was a memory leak in that area of the
code related to how funcfullsig and aggfullsig were conditionally
assigned values, but not freed.

The attached patch fixes this memory leak;  not sure if this should be
back-patched.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +

Вложения

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Claudio Freire
Дата:
Сообщение: Re: BUG #9161: wal_writer_delay is limited to 10s
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: Bad behaviour on some geometric operations on degenerate polygons