Segfault in backend CTE code

Поиск
Список
Период
Сортировка
От Phil Sorber
Тема Segfault in backend CTE code
Дата
Msg-id CADAkt-iWfSvovEMd4-sT15OQ+YK4FC_YbZDefxwUK5EwrWe4bA@mail.gmail.com
обсуждение исходный текст
Ответы Re: Segfault in backend CTE code  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
Running Postgres 9.1.2.

I've attached a backtrace. Looking at the backtrace it looks like
ExecGetResultType() gets called with a NULL planstate and causes the
segmentation fault:

https://github.com/postgres/postgres/blob/master/src/backend/executor/execUtils.c#L470

Following the stack I see that an optimization for writeable CTE's
inserts a NULL subplanstate:

https://github.com/postgres/postgres/blob/master/src/backend/executor/execMain.c#L2344

ExecInitCteScan() is what eventually passes it to ExecGetResultType():

https://github.com/postgres/postgres/blob/master/src/backend/executor/nodeCtescan.c#L255

I've also attached a proposed fix. In this optimized case it says that
we won't ever use the subplan anyway, so I figured that not setting
the scan tuple type won't matter. I also added an Assert() to
ExecGetResultType(). I modified the declaration of 'slot' to remove a
compiler warning. This patch is against master but should backport to
9.1 cleanly. It also passed all regression tests. If you end up using
this patch please also credit Rick Pufky who helped me with this.

Вложения

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

Предыдущее
От: Bridget Frey
Дата:
Сообщение: Re: BUG #6200: standby bad memory allocations on SELECT
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Segfault in backend CTE code