Re: BUG #16283: crash on create index segmentation fault

From: Przemysław Szustak <przemyslaw(dot)szustak(at)gmail(dot)com>
To: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16283: crash on create index segmentation fault
Date: 2020-03-03 16:08:18
Message-ID: CAJo3-jhz+2rK3gYj2Lq7FKaVW1neLtByn=LXXeSdo6qK+BDNbw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

OK, once again all info:

Used versions:
Postgresql:
psql -p 5432 -c "select version()" -d "test_crash"
return:
PostgreSQL 10.12 (Ubuntu 10.12-2.pgdg16.04+1) on
x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0
20160609, 64-bit
Postgis:
psql -p 5432 -c "select postgis_full_version()" -d "test_crash"
return:
POSTGIS="2.5.3 r17699" [EXTENSION] PGSQL="100"
GEOS="3.7.1-CAPI-1.11.1 27a5e771" PROJ="Rel. 4.9.2, 08 September 2015"
GDAL="GDAL 1.11.3, released 2015/09/16" LIBXML="2.9.3" LIBJSON="0.11.99"
LIBPROTOBUF="1.2.1" RASTER
System:
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial
uname -a
Linux 4.4.0-165-generic #193-Ubuntu SMP Tue Sep 17 17:42:52 UTC
2019 x86_64 x86_64 x86_64 GNU/Linux

How to restore crash:
1. Create DB:
psql -p 5432 -c "create database test_crash"
2. Add postgis:
psql -p 5432 -c "create extension postgis" -d "test_crash"
3. Import data to DB (file "test_table.sql" in attachment):
psql -p 5432 -f "./test_table.sql" -d "test_crash"
4. Exec SQL:
psql -p 5432 -c "drop index if exists test_table_geom_idx; CREATE
INDEX test_table_geom_idx ON public.test_table USING gist(st_intersection
gist_geometry_ops_nd) TABLESPACE pg_default;" -d "test_crash"
5. Program terminated with signal SIGSEGV, Segmentation fault.

How I generate crash and bt log (using your information and PostGIS
tutorial https://trac.osgeo.org/postgis/wiki/DevWikiGettingABackTrace).
1. Login as postgres:
sudo su; su postgres

2. Open psql console:
psql -p 5432 -d "test_crash".

3. I try to check running pid:
select postgis_full_version(), pg_backend_pid();
return:

postgis_full_version
|
pg_backend_pid

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------
POSTGIS="2.5.3 r17699" [EXTENSION] PGSQL="100"
GEOS="3.7.1-CAPI-1.11.1 27a5e771" PROJ="Rel. 4.9.2, 08 September 2015"
GDAL="GDAL 1.11.3, released 2015/09/16" LIBXML="2.9.3" LIBJSON="0.11.99"
LIBPROTOBUF="1.2.1" RASTER | 30691
(1 row)

4. In other console:
sudo su;
gdb -p 30691

5. In first console (in psql) I run crash SQL:
drop index if exists test_table_geom_idx; CREATE INDEX
test_table_geom_idx ON public.test_table USING gist(st_intersection
gist_geometry_ops_nd) TABLESPACE pg_default;

6. In secend console (gdb) I press c
(gbd) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
pfree (pointer=0x7f7a6ec008f8) at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/utils/mmgr/mcxt.c:954
954
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/utils/mmgr/mcxt.c:
Nie ma takiego pliku ani katalogu.

(gdb) bt
#0 pfree (pointer=0x7f7a6ec008f8) at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/utils/mmgr/mcxt.c:954
#1 0x00007f7a65c0eb5e in ?? () from /usr/lib/postgresql/10/lib/
postgis-2.5.so
#2 0x00007f7a65c10367 in gserialized_gist_picksplit () from
/usr/lib/postgresql/10/lib/postgis-2.5.so
#3 0x000055b80d1f6272 in FunctionCall2Coll
(flinfo=flinfo(at)entry=0x55b80ef2dac8,
collation=<optimized out>, arg1=arg1(at)entry=94249013099592,
arg2=arg2(at)entry=140736435822256)
at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/utils/fmgr/fmgr.c:1059
#4 0x000055b80ce3b526 in gistUserPicksplit (len=227,
giststate=0x55b80ef2bca8, itup=0x55b80ef21d18, v=0x7fffc1439eb0, attno=0,
entryvec=0x55b80ef23c48, r=0x7f7a5705d668)
at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/access/gist/gistsplit.c:433
#5 gistSplitByKey (r=r(at)entry=0x7f7a5705d668,
page=page(at)entry=0x7f7a6ebfea00
"", itup=itup(at)entry=0x55b80ef21d18, len=len(at)entry=227,
giststate=giststate(at)entry=0x55b80ef2bca8, v=v(at)entry=0x7fffc1439eb0, attno=0)
at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/access/gist/gistsplit.c:697
#6 0x000055b80ce3252c in gistSplit (r=r(at)entry=0x7f7a5705d668,
page=page(at)entry=0x7f7a6ebfea00 "", itup=0x55b80ef21d18, len=227,
giststate=giststate(at)entry=0x55b80ef2bca8) at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/access/gist/gist.c:1375
#7 0x000055b80ce32952 in gistplacetopage (rel=0x7f7a5705d668,
freespace=<optimized out>, giststate=giststate(at)entry=0x55b80ef2bca8,
buffer=1541, itup=itup(at)entry=0x7fffc143a388, ntup=ntup(at)entry=1,
oldoffnum=0, newblkno=0x0, leftchildbuf=0, splitinfo=0x7fffc143a2c0,
markfollowright=1 '\001', heapRel=0x7f7a5705c658) at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/access/gist/gist.c:295
#8 0x000055b80ce3341e in gistinserttuples
(state=state(at)entry=0x7fffc143a390,
stack=stack(at)entry=0x7fffc143a3b0, giststate=giststate(at)entry=0x55b80ef2bca8,
tuples=tuples(at)entry=0x7fffc143a388, ntup=ntup(at)entry=1,
oldoffnum=oldoffnum(at)entry=0, leftchild=0, rightchild=0,
unlockbuf=0 '\000', unlockleftchild=0 '\000') at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/access/gist/gist.c:1221
#9 0x000055b80ce3382a in gistinserttuple (oldoffnum=0,
tuple=0x55b80ef21ce8, giststate=0x55b80ef2bca8, stack=0x7fffc143a3b0,
state=0x7fffc143a390) at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/access/gist/gist.c:1180
#10 gistdoinsert (r=r(at)entry=0x7f7a5705d668,
itup=itup(at)entry=0x55b80ef21ce8,
freespace=<optimized out>, giststate=0x55b80ef2bca8, heapRel=<optimized
out>) at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/access/gist/gist.c:837
#11 0x000055b80ce3cd11 in gistBuildCallback
(index=index(at)entry=0x7f7a5705d668,
htup=htup(at)entry=0x55b80eec6f80, values=values(at)entry=0x7fffc143a590,
isnull=isnull(at)entry=0x7fffc143a8e0 "", tupleIsAlive=tupleIsAlive(at)entry=1
'\001', state=state(at)entry=0x7fffc143a9a0)
at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/access/gist/gistbuild.c:488
#12 0x000055b80ceb15e7 in IndexBuildHeapRangeScan
(heapRelation=heapRelation(at)entry=0x7f7a5705c658,
indexRelation=indexRelation(at)entry=0x7f7a5705d668,
indexInfo=indexInfo(at)entry=0x55b80eec6378,
allow_sync=allow_sync(at)entry=1 '\001', anyvisible=anyvisible(at)entry=0 '\000',
start_blockno=start_blockno(at)entry=0, numblocks=4294967295,
callback=0x55b80ce3cc80 <gistBuildCallback>, callback_state=0x7fffc143a9a0)
at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/catalog/index.c:2701
#13 0x000055b80ceb1b0c in IndexBuildHeapScan
(heapRelation=heapRelation(at)entry=0x7f7a5705c658,
indexRelation=indexRelation(at)entry=0x7f7a5705d668,
indexInfo=indexInfo(at)entry=0x55b80eec6378,
allow_sync=allow_sync(at)entry=1 '\001',
callback=callback(at)entry=0x55b80ce3cc80 <gistBuildCallback>,
callback_state=callback_state(at)entry=0x7fffc143a9a0) at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/catalog/index.c:2271
#14 0x000055b80ce3d380 in gistbuild (heap=0x7f7a5705c658,
index=0x7f7a5705d668, indexInfo=0x55b80eec6378) at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/access/gist/gistbuild.c:207
#15 0x000055b80ceb2923 in index_build
(heapRelation=heapRelation(at)entry=0x7f7a5705c658,
indexRelation=indexRelation(at)entry=0x7f7a5705d668,
indexInfo=indexInfo(at)entry=0x55b80eec6378,
isprimary=isprimary(at)entry=0 '\000', isreindex=isreindex(at)entry=0 '\000')
at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/catalog/index.c:2132
#16 0x000055b80ceb42b9 in index_create
(heapRelation=heapRelation(at)entry=0x7f7a5705c658,
indexRelationName=indexRelationName(at)entry=0x55b80eec6738
"test_table_geom_idx", indexRelationId=599550, indexRelationId(at)entry=0,
relFileNode=<optimized out>,
indexInfo=indexInfo(at)entry=0x55b80eec6378,
indexColNames=indexColNames(at)entry=0x55b80eec7388, accessMethodObjectId=783,
tableSpaceId=1663, collationObjectId=0x55b80eec73d0,
classObjectId=0x55b80eec73e8, coloptions=0x55b80eec7400, reloptions=0,
isprimary=0 '\000',
isconstraint=0 '\000', deferrable=0 '\000', initdeferred=0
'\000', allow_system_table_mods=0 '\000', skip_build=0 '\000', concurrent=0
'\000', is_internal=0 '\000', if_not_exists=0 '\000')
at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/catalog/index.c:1133
#17 0x000055b80cf518b0 in DefineIndex (relationId=<optimized out>,
relationId(at)entry=534024, stmt=stmt(at)entry=0x55b80eec6768,
indexRelationId=indexRelationId(at)entry=0, is_alter_table=is_alter_table(at)entry=0
'\000', check_rights=check_rights(at)entry=1 '\001',
check_not_in_use=check_not_in_use(at)entry=1 '\001', skip_build=0
'\000', quiet=0 '\000') at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/commands/indexcmds.c:682
#18 0x000055b80d0e2f80 in ProcessUtilitySlow
(pstate=pstate(at)entry=0x55b80eec6218,
pstmt=pstmt(at)entry=0x55b80ee123c0,
queryString=queryString(at)entry=0x55b80ee11358 "CREATE INDEX
test_table_geom_idx ON public.test_table USING gist(st_intersection
gist_geometry_ops_nd) TABLESPACE pg_default;",
context=context(at)entry=PROCESS_UTILITY_TOPLEVEL,
params=params(at)entry=0x0,
queryEnv=queryEnv(at)entry=0x0, completionTag=0x7fffc143b3f0 "",
dest=0x55b80ee124a0) at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/tcop/utility.c:1336
#19 0x000055b80d0e1f87 in standard_ProcessUtility
(pstmt=0x55b80ee123c0, queryString=0x55b80ee11358 "CREATE INDEX
test_table_geom_idx ON public.test_table USING gist(st_intersection
gist_geometry_ops_nd) TABLESPACE pg_default;",
context=PROCESS_UTILITY_TOPLEVEL,
params=0x0, queryEnv=0x0, dest=0x55b80ee124a0,
completionTag=0x7fffc143b3f0 "") at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/tcop/utility.c:931
#20 0x000055b80d0defab in PortalRunUtility (portal=0x55b80edab5a8,
pstmt=0x55b80ee123c0, isTopLevel=<optimized out>,
setHoldSnapshot=<optimized out>, dest=<optimized out>,
completionTag=0x7fffc143b3f0 "")
at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/tcop/pquery.c:1178
#21 0x000055b80d0dfa98 in PortalRunMulti
(portal=portal(at)entry=0x55b80edab5a8,
isTopLevel=isTopLevel(at)entry=1 '\001', setHoldSnapshot=setHoldSnapshot(at)entry=0
'\000', dest=dest(at)entry=0x55b80ee124a0, altdest=altdest(at)entry=0x55b80ee124a0,

completionTag=completionTag(at)entry=0x7fffc143b3f0 "") at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/tcop/pquery.c:1331
#22 0x000055b80d0e0805 in PortalRun
(portal=portal(at)entry=0x55b80edab5a8,
count=count(at)entry=9223372036854775807, isTopLevel=isTopLevel(at)entry=1
'\001', run_once=run_once(at)entry=1 '\001', dest=dest(at)entry=0x55b80ee124a0,
altdest=altdest(at)entry=0x55b80ee124a0,
completionTag=0x7fffc143b3f0 "") at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/tcop/pquery.c:799
#23 0x000055b80d0dc2bc in exec_simple_query
(query_string=0x55b80ee11358 "CREATE INDEX test_table_geom_idx ON
public.test_table USING gist(st_intersection gist_geometry_ops_nd)
TABLESPACE pg_default;")
at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/tcop/postgres.c:1122
#24 0x000055b80d0dd7e8 in PostgresMain (argc=<optimized out>,
argv=argv(at)entry=0x55b80edb10c0, dbname=0x55b80edb0f88 "test_crash",
username=<optimized out>) at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/tcop/postgres.c:4128
#25 0x000055b80ce1187e in BackendRun (port=0x55b80eda76a0) at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/postmaster/postmaster.c:4408
#26 BackendStartup (port=0x55b80eda76a0) at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/postmaster/postmaster.c:4080
#27 ServerLoop () at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/postmaster/postmaster.c:1756
#28 0x000055b80d06b819 in PostmasterMain (argc=5, argv=<optimized
out>) at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/postmaster/postmaster.c:1364
#29 0x000055b80ce12c75 in main (argc=5, argv=0x55b80ed5a850) at
/build/postgresql-10-0Kn02a/postgresql-10-10.12/build/../src/backend/main/main.c:228
(gdb) c
Continuing.

7. When I press c in gdb secend time then in first psql I received:
UWAGA: indeks "test_table_geom_idx" nie istnieje, pominięto
DROP INDEX
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.

8. When I try to continue or bt in gdb I received:
Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
(gdb) bt
No stack.
(gdb) c
The program is not being run.
(gdb)

Attachment Content-Type Size
test_table.sql application/sql 3.5 MB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Arseny Sher 2020-03-04 13:29:44 Re: ERROR: subtransaction logged without previous top-level txn record
Previous Message Tom Lane 2020-03-03 14:34:31 Re: BUG #16286: Некорректно работает функция lower