Re: memory leak in pgoutput

Поиск
Список
Период
Сортировка
От by Yang
Тема Re: memory leak in pgoutput
Дата
Msg-id DM3PR84MB3442C5736F1207066CFBCC88E3272@DM3PR84MB3442.NAMPRD84.PROD.OUTLOOK.COM
обсуждение исходный текст
Ответ на RE: memory leak in pgoutput  ("Zhijie Hou (Fujitsu)" <houzj.fnst@fujitsu.com>)
Список pgsql-hackers

> Here, after freeing the tupledesc, the ExecDropSingleTupleTableSlot will still

> access the freed tupledesc->tdrefcount which is an illegal memory access.

 

Yes, I overlooked that.

 

> I think we can do something like below instead:

>

> +                       TupleDesc       desc = entry->old_slot->tts_tupleDescriptor;

> +

> +                       Assert(desc->tdrefcount == -1);

> +

>                         ExecDropSingleTupleTableSlot(entry->old_slot);

> +                       FreeTupleDesc(desc);

 

It seems a bit odd because "entry->old_slot->tts_tupleDescriptor" is accessed

after "entry->old_slot" has been freed. I think we can avoid this by assigning

"desc" to NULL before ExecDropSingleTupleTableSlot().

 

```

+                                              TupleDesc       desc = entry->old_slot->tts_tupleDescriptor;

+

+                                              Assert(desc->tdrefcount == -1);

+

+                                              FreeTupleDesc(desc);

+                                              desc = NULL;

                                               ExecDropSingleTupleTableSlot(entry->old_slot);

```

 

By the way, this issue is introduced in 52e4f0cd472d39d. Therefore, we may need

to backport the patch to v15.

 

Best Regards,

Boyu Yang

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