[postgis-tickets] [PostGIS] #4674: lwgeom_cache doesn't live through not inline functions
PostGIS
trac at osgeo.org
Mon May 4 02:46:58 PDT 2020
#4674: lwgeom_cache doesn't live through not inline functions
-------------------------+---------------------------
Reporter: Raúl Marín | Owner: pramsey
Type: defect | Status: reopened
Priority: medium | Milestone: PostGIS 3.1.0
Component: postgis | Version: master
Resolution: | Keywords:
-------------------------+---------------------------
Comment (by Raúl Marín):
I tried reverting this change but it seems that `fcinfo->flinfo` might be
NULL in some cases and it's crashing with the new geojson cache:
{{{
(gdb) bt
#0 0x00007f24776bda8a in GetGenericCacheCollection
(fcinfo=0x7ffe6199df80) at lwgeom_cache.c:79
#1 SRIDCacheGet (fcinfo=0x7ffe6199df80) at lwgeom_cache.c:506
#2 GetSRIDCacheBySRS (fcinfo=0x7ffe6199df80, srs=0x558057f24260
"EPSG:3005") at lwgeom_cache.c:520
#3 0x00007f24776517fd in LWGEOM_in (fcinfo=0x7ffe6199df80) at
lwgeom_inout.c:150
#4 0x0000558056faab75 in DirectFunctionCall1Coll (func=0x7f2477651670
<LWGEOM_in>, collation=1475494496, arg1=0) at fmgr.c:803
#5 0x00007f247765257e in parse_WKT_lwgeom (fcinfo=0x558057eef4f0) at
lwgeom_inout.c:662
#6 0x0000558056cc350d in ExecInterpExpr (state=0x558057eef410,
econtext=0x558057eef570, isnull=<optimized out>) at execExprInterp.c:649
#7 0x0000558056d92a8e in ExecEvalExprSwitchContext (state=<optimized
out>, econtext=0x558057f24260, isNull=0x7ffe6199e11f) at
../../../../src/include/executor/executor.h:307
#8 evaluate_expr (expr=<optimized out>, result_type=10775331,
result_typmod=-1, result_collation=0) at clauses.c:4812
#9 0x0000558056d93664 in evaluate_function (funcid=10775691,
result_type=10775331, result_typmod=-1, result_collid=0, input_collid=100,
args=0x55805832d138, funcvariadic=<optimized out>, context=0x7ffe6199e660,
func_tuple=<optimized out>)
at clauses.c:4354
#10 simplify_function (funcid=10775691, result_type=10775331,
result_typmod=-1, result_collid=0, input_collid=100, args_p=<optimized
out>, funcvariadic=<optimized out>, process_args=<optimized out>,
allow_non_const=true, context=0x7ffe6199e660)
at clauses.c:3984
#11 0x0000558056d91864 in eval_const_expressions_mutator
(node=0x558057e0a1b0, context=0x7ffe6199e660) at clauses.c:2477
#12 0x0000558056d26b06 in expression_tree_mutator (node=<optimized out>,
mutator=0x558056d90c30 <eval_const_expressions_mutator>,
context=0x7ffe6199e660) at nodeFuncs.c:3012
#13 0x0000558056d933e0 in simplify_function (funcid=10775573,
result_type=25, result_typmod=-1, result_collid=100, input_collid=0,
args_p=0x7ffe6199e470, funcvariadic=<optimized out>,
process_args=<optimized out>, allow_non_const=<optimized out>,
context=0x7ffe6199e660) at clauses.c:3975
#14 0x0000558056d91864 in eval_const_expressions_mutator
(node=0x55805832c5b8, context=0x7ffe6199e660) at clauses.c:2477
#15 0x0000558056d26829 in expression_tree_mutator (node=0x55805832c608,
mutator=0x558056d90c30 <eval_const_expressions_mutator>,
context=0x7ffe6199e660) at nodeFuncs.c:2762
#16 0x0000558056d90d4e in eval_const_expressions_mutator
(node=0x55805832c608, context=0x7ffe6199e660) at clauses.c:3539
#17 0x0000558056d26b06 in expression_tree_mutator (node=<optimized out>,
mutator=0x558056d90c30 <eval_const_expressions_mutator>,
context=0x7ffe6199e660) at nodeFuncs.c:3012
#18 0x0000558056d90d4e in eval_const_expressions_mutator
(node=0x558057e099d0, context=0x7ffe6199e660) at clauses.c:3539
#19 0x0000558056d90c10 in eval_const_expressions (root=<optimized out>,
node=0x0) at clauses.c:2269
#20 0x0000558056d794ab in preprocess_expression (root=<optimized out>,
expr=0x558057f24260, kind=1) at planner.c:1087
#21 subquery_planner (glob=<optimized out>, parse=0x558057e09800,
parent_root=<optimized out>, hasRecursion=<optimized out>,
tuple_fraction=0) at planner.c:769
#22 0x0000558056d78aaf in standard_planner (parse=0x558057e09800,
cursorOptions=<optimized out>, boundParams=0x0) at planner.c:406
#23 0x0000558056e51e60 in pg_plan_query (querytree=0x558057e09800,
cursorOptions=256, boundParams=0x0) at postgres.c:878
#24 pg_plan_queries (querytrees=<optimized out>, cursorOptions=256,
boundParams=0x0) at postgres.c:968
#25 0x0000558056e562b4 in exec_simple_query (query_string=0x558057e08500
"SELECT 'cast2', ST_AsEWKT(st_asgeojson('SRID=3005;MULTIPOINT(1 1, 1
1)'::geometry)::geometry);") at postgres.c:1143
#26 0x0000558056e53d34 in PostgresMain (argc=<optimized out>,
argv=<optimized out>, dbname=<optimized out>, username=<optimized out>) at
postgres.c:4243
#27 0x0000558056dc2ef7 in BackendRun (port=0x558057e2f5b0) at
postmaster.c:4437
#28 0x0000558056dc24df in BackendStartup (port=<optimized out>) at
postmaster.c:4128
#29 ServerLoop () at postmaster.c:1704
#30 0x0000558056dbf036 in PostmasterMain (argc=3, argv=0x558057e02230) at
postmaster.c:1377
#31 0x0000558056d247d5 in main (argc=3, argv=0x558057e02230) at main.c:228
(gdb) f 0
#0 0x00007f24776bda8a in GetGenericCacheCollection
(fcinfo=0x7ffe6199df80) at lwgeom_cache.c:79
79 GenericCacheCollection* cache = fcinfo->flinfo->fn_extra;
(gdb) p *fcinfo
$6 = {flinfo = 0x0, context = 0x0, resultinfo = 0x0, fncollation = 0,
isnull = false, nargs = 1, args = 0x7ffe6199dfa0}
}}}
It seems that DirectFunctionCall1 needs to be replaced by
CallerFInfoFunctionCall1 to ensure `flinfo` is initialized.
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4674#comment:7>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list