Re: [PATCH] Make gram.y use palloc/pfree for memory management

Поиск
Список
Период
Сортировка
От Marko Kreen
Тема Re: [PATCH] Make gram.y use palloc/pfree for memory management
Дата
Msg-id e51f66da0809010633q5d0f999br72fe9dedf3b47760@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [PATCH] Make gram.y use palloc/pfree for memory management  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [PATCH] Make gram.y use palloc/pfree for memory management
Список pgsql-hackers
First a correction, overriding malloc/free seems dangerous they
seems to leak out, so correct would be to use YYMALLOC/YYFREE.
This leaves 1.875 potentially leaking, but danger seems small.

On 9/1/08, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Marko Kreen <markokr@gmail.com> writes:
>  > This means gram.y can leak memory if error is throws in
>  > the middle of parsing.
>
> Please offer some evidence for that claim.

The leak occurs when
1. bison does allocation.
2. error is thrown.

Now, normally bison does not do allocation as it has initially 200-item
stack allocated in stack.  When this is full it does allocate.

But I'm not familial enough with bison internals and Postgres parser
structure, on how cause the stack fill up.  It may be that Postgres
parser avoids recursive stack allocations, thus in practice the
leak cannot occur.

-- 
marko


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

Предыдущее
От: Hannu Krosing
Дата:
Сообщение: Re: Is this really really as designed or defined in some standard
Следующее
От: "Marko Kreen"
Дата:
Сообщение: Re: [PATCH] Cleanup of GUC units code