BUG #16329: Valgrind detects an invalid read when building a gist index with buffering
The Post Office <noreply@postgresql.org>
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: exclusion@gmail.com
Date: 2020-03-29T21:00:01Z
Lists: pgsql-bugs
The following bug has been logged on the website: Bug reference: 16329 Logged by: Alexander Lakhin Email address: exclusion@gmail.com PostgreSQL version: 12.2 Operating system: Ubuntu 18.04 Description: Running the following query under valgrind: create table gist_point_tbl(id int4, p point); insert into gist_point_tbl (id, p) select g, point(g*10+1, g*10+1) from generate_series(1, 30000) g; create index gist_pointidx2 on gist_point_tbl using gist(p) with (buffering = on, fillfactor=50); leads to a memory access error: ==00:00:00:08.755 18585== Invalid read of size 2 ==00:00:00:08.756 18585== at 0x1F94CA: gistBuildCallback (gistbuild.c:495) ==00:00:00:08.756 18585== by 0x21F556: heapam_index_build_range_scan (heapam_handler.c:1664) ==00:00:00:08.756 18585== by 0x1F972F: table_index_build_scan (tableam.h:1522) ==00:00:00:08.756 18585== by 0x1F972F: gistbuild (gistbuild.c:196) ==00:00:00:08.756 18585== by 0x29D1FE: index_build (index.c:2909) ==00:00:00:08.756 18585== by 0x29EAC8: index_create (index.c:1221) ==00:00:00:08.756 18585== by 0x348C60: DefineIndex (indexcmds.c:1005) ==00:00:00:08.756 18585== by 0x52B518: ProcessUtilitySlow (utility.c:1372) ==00:00:00:08.756 18585== by 0x52AAC5: standard_ProcessUtility (utility.c:927) ==00:00:00:08.756 18585== by 0x52AB73: ProcessUtility (utility.c:360) ==00:00:00:08.756 18585== by 0x527025: PortalRunUtility (pquery.c:1175) ==00:00:00:08.756 18585== by 0x527C6F: PortalRunMulti (pquery.c:1321) ==00:00:00:08.756 18585== by 0x5289DE: PortalRun (pquery.c:796) ==00:00:00:08.756 18585== Address 0x8a4ca1e is 398 bytes inside a block of size 8,192 alloc'd ==00:00:00:08.756 18585== at 0x4C2FBFF: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==00:00:00:08.756 18585== by 0x6781E6: AllocSetContextCreateInternal (aset.c:477) ==00:00:00:08.756 18585== by 0x3BF065: ExecInitFunctionScan (nodeFunctionscan.c:508) ==00:00:00:08.756 18585== by 0x3ACE6F: ExecInitNode (execProcnode.c:247) ==00:00:00:08.756 18585== by 0x3D03E1: ExecInitModifyTable (nodeModifyTable.c:2363) ==00:00:00:08.756 18585== by 0x3ACD4C: ExecInitNode (execProcnode.c:174) ==00:00:00:08.756 18585== by 0x3A70F3: InitPlan (execMain.c:1020) ==00:00:00:08.756 18585== by 0x3A7299: standard_ExecutorStart (execMain.c:266) ==00:00:00:08.756 18585== by 0x3A739B: ExecutorStart (execMain.c:148) ==00:00:00:08.756 18585== by 0x527936: ProcessQuery (pquery.c:156) ==00:00:00:08.756 18585== by 0x527B34: PortalRunMulti (pquery.c:1283) ==00:00:00:08.756 18585== by 0x5289DE: PortalRun (pquery.c:796) Reproduced at least on REL_10_STABLE..master.
Commits
-
Fix dereference of dangling pointer in GiST index buffering build.
- d2a1d4b190ec 12.15 landed
- b5c6776c1127 11.20 landed
- a1904c9ce56a 14.8 landed
- 8e5eef50c5b4 16.0 landed
- 2dc77adc768e 15.3 landed
- 2adb6adad5f8 13.11 landed
-
Fix GiST buffering build to work when there are included columns.
- 962ab473ec3d 13.1 landed
- 371668a8389d 14.0 landed
- 12945874ebd6 12.5 landed
-
Re-allow testing of GiST buffered builds.
- 78c0b6ed273a 14.0 landed
-
Add support for building GiST index by sorting.
- 16fa9b2b30a3 14.0 cited