Patch to fix write after end of array in hashed agg initialization

Поиск
Список
Период
Сортировка
От Colm McHugh
Тема Patch to fix write after end of array in hashed agg initialization
Дата
Msg-id CAFeeJoKKu0u+A_A9R9316djW-YW3-+Gtgvy3ju655qRHR3jtdA@mail.gmail.com
обсуждение исходный текст
Ответы Re: Patch to fix write after end of array in hashed agg initialization  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers

Attached is a patch for a write after allocated memory which we found in testing. Its an obscure case but can happen if the same column is used in different grouping keys, as in the example below, which uses tables from the regress test suite (build with --enable-cassert in order to turn on memory warnings). Patch is against master.

The hashed aggregate state has an array for the column indices that is sized using the number of non-aggregated columns in the set that includes the agg's targetlist, quals and input grouping columns. The duplicate elimination of columns can result in under-allocation, as below. Sizing based on the number of grouping columns and number of quals/targetlists not in the grouping columns avoids this.

Regards,
Colm McHugh (Salesforce)

explain (costs off) select 1 from tenk where (hundred, thousand) in (select twothousand, twothousand from onek);

psql: WARNING:  problem in alloc set ExecutorState: detected write past chunk end in block 0x7f8b8901fa00, chunk 0x7f8b89020cd0

psql: WARNING:  problem in alloc set ExecutorState: detected write past chunk end in block 0x7f8b8901fa00, chunk 0x7f8b89020cd0

                         QUERY PLAN                          

-------------------------------------------------------------

 Hash Join

   Hash Cond: (tenk.hundred = onek.twothousand)

   ->  Seq Scan on tenk

         Filter: (hundred = thousand)

   ->  Hash

         ->  HashAggregate

               Group Key: onek.twothousand, onek.twothousand

               ->  Seq Scan on onek

(8 rows)
Вложения

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

Предыдущее
От: Melanie Plageman
Дата:
Сообщение: Re: accounting for memory used for BufFile during hash joins
Следующее
От: Michael Meskes
Дата:
Сообщение: Re: SQL statement PREPARE does not work in ECPG