Re: BUG #16329: Valgrind detects an invalid read when building a gist index with buffering

From: Alexander Lakhin <exclusion(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16329: Valgrind detects an invalid read when building a gist index with buffering
Date: 2020-05-12 05:00:01
Message-ID: 06f117b8-bbc1-4190-d204-ef329121cbca@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

11.05.2020 23:00, Alexander Lakhin wrote:
> Please look at the improved test that makes the code coverage for
> gistbuildbuffers.c almost 100%.
That improved test exposes another bug (when running under valgrind):

==00:00:00:34.861 1439277== Conditional jump or move depends on
uninitialised value(s)
==00:00:00:34.861 1439277==    at 0x1FFE6A: gistpenalty (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F86E0:
gistRelocateBuildBuffersOnSplit (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F67B7: gistbufferinginserttuples
(in .../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F6B6F: gistbufferinginserttuples
(in .../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F6E0E: gistProcessItup (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F701F: gistProcessEmptyingQueue (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F706D: gistBufferingBuildInsert (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F7817: gistBuildCallback (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x2293F3:
heapam_index_build_range_scan (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F7A23: gistbuild (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x2B8372: index_build (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x2B9C8D: index_create (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==  Uninitialised value was created by a heap
allocation
==00:00:00:34.861 1439277==    at 0x6B646A: palloc (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F5A8A: initGISTstate (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F7913: gistbuild (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x2B8372: index_build (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x2B9C8D: index_create (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x361677: DefineIndex (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x563FE3: ProcessUtilitySlow (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x56358F: standard_ProcessUtility (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x56366E: ProcessUtility (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x55FAED: PortalRunUtility (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x560640: PortalRunMulti (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x5612F8: PortalRun (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:gistpenalty
   fun:gistRelocateBuildBuffersOnSplit
   fun:gistbufferinginserttuples
   fun:gistbufferinginserttuples
   fun:gistProcessItup
   fun:gistProcessEmptyingQueue
   fun:gistBufferingBuildInsert
   fun:gistBuildCallback
   fun:heapam_index_build_range_scan
   fun:gistbuild
   fun:index_build
   fun:index_create
}
==00:00:00:34.861 1439277== Use of uninitialised value of size 8
==00:00:00:34.861 1439277==    at 0x68E92D: FunctionCall3Coll (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==  Uninitialised value was created by a heap
allocation
==00:00:00:34.861 1439277==    at 0x6B646A: palloc (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F5A8A: initGISTstate (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F7913: gistbuild (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x2B8372: index_build (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x2B9C8D: index_create (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x361677: DefineIndex (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x563FE3: ProcessUtilitySlow (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x56358F: standard_ProcessUtility (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x56366E: ProcessUtility (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x55FAED: PortalRunUtility (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x560640: PortalRunMulti (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x5612F8: PortalRun (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==
{
   <insert_a_suppression_name_here>
   Memcheck:Value8
   fun:FunctionCall3Coll
}
==00:00:00:34.861 1439277== Jump to the invalid address stated on the
next line
==00:00:00:34.861 1439277==    at 0x0: ???
==00:00:00:34.861 1439277==    by 0x68E92E: FunctionCall3Coll (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1FFE9F: gistpenalty (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F86E0:
gistRelocateBuildBuffersOnSplit (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F67B7: gistbufferinginserttuples
(in .../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F6B6F: gistbufferinginserttuples
(in .../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F6E0E: gistProcessItup (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F701F: gistProcessEmptyingQueue (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F706D: gistBufferingBuildInsert (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F7817: gistBuildCallback (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x2293F3:
heapam_index_build_range_scan (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F7A23: gistbuild (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==  Address 0x0 is not stack'd, malloc'd or
(recently) free'd
==00:00:00:34.861 1439277==
{
   <insert_a_suppression_name_here>
   Memcheck:Jump
   obj:*
   fun:FunctionCall3Coll
   fun:gistpenalty
   fun:gistRelocateBuildBuffersOnSplit
   fun:gistbufferinginserttuples
   fun:gistbufferinginserttuples
   fun:gistProcessItup
   fun:gistProcessEmptyingQueue
   fun:gistBufferingBuildInsert
   fun:gistBuildCallback
   fun:heapam_index_build_range_scan
   fun:gistbuild
}
==00:00:00:34.861 1439277==
==00:00:00:34.861 1439277== Process terminating with default action of
signal 11 (SIGSEGV): dumping core
==00:00:00:34.861 1439277==  Bad permissions for mapped region at
address 0x0
==00:00:00:34.861 1439277==    at 0x0: ???
==00:00:00:34.861 1439277==    by 0x68E92E: FunctionCall3Coll (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1FFE9F: gistpenalty (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F86E0:
gistRelocateBuildBuffersOnSplit (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F67B7: gistbufferinginserttuples
(in .../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F6B6F: gistbufferinginserttuples
(in .../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F6E0E: gistProcessItup (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F701F: gistProcessEmptyingQueue (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F706D: gistBufferingBuildInsert (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F7817: gistBuildCallback (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x2293F3:
heapam_index_build_range_scan (in
.../tmp_install/usr/local/pgsql/bin/postgres)
==00:00:00:34.861 1439277==    by 0x1F7A23: gistbuild (in
.../tmp_install/usr/local/pgsql/bin/postgres)
2020-05-12 06:51:30.764 MSK postmaster[1439231] LOG:  server process
(PID 1439277) was terminated by signal 11: Segmentation fault
2020-05-12 06:51:30.764 MSK postmaster[1439231] DETAIL:  Failed process
was running: create index gist_pointidx6 on gist_point_tbl using gist(p)
include(t) with (buffering = on, fillfactor=50);

Best regards,
Alexander

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Per-Åke Ling 2020-05-12 12:28:43 Substring expression fails on single character input
Previous Message Justin Pryzby 2020-05-11 22:46:23 Re: translation typos