Opened 7 months ago

Closed 5 months ago

#4382 closed defect (fixed)

ST_Union of subdivided polygon fails on debbie

Reported by: komzpa Owned by: pramsey
Priority: medium Milestone: PostGIS 3.0.0
Component: postgis Version: 2.4.x
Keywords: Cc:

Description

Reproduces on debbie, not locally or on Travis. Traces go to GEOS SRID handling.

-----------------------------------------------------------------------------
make[2]: *** [Makefile:215: check] Error 1
make[2]: Leaving directory '/var/lib/jenkins/workspace/postgis/branches/3.0/regress/core'
make[1]: *** [Makefile:43: check] Error 2
make[1]: Leaving directory '/var/lib/jenkins/workspace/postgis/branches/3.0/regress'
make: *** [GNUmakefile:20: check] Error 1
[logbt] saw 'make' exit with code:2 (INT)
[logbt] Found corefile (non-tracked) at /tmp/logbt-coredumps/core.690.!var!lib!jenkins!workspace!pg!rel!pg10w64!bin!postgres
[logbt] Processing cores...
[New LWP 690]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `postgres: postgres postgis_reg [local] SELECT                                 '.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007fe7051ae0d6 in geos::geom::GeometryCollection::GeometryCollection (this=0x559b48811fb0, newGeoms=<optimized out>, factory=<optimized out>, __in_chrg=<optimized out>, __vtt_parm=<optimized out>) at ../../include/geos/geom/Geometry.h:271
271	        return SRID;

Thread 1 (Thread 0x7fe70ef50300 (LWP 690)):
#0  0x00007fe7051ae0d6 in geos::geom::GeometryCollection::GeometryCollection (this=0x559b48811fb0, newGeoms=<optimized out>, factory=<optimized out>, __in_chrg=<optimized out>, __vtt_parm=<optimized out>) at ../../include/geos/geom/Geometry.h:271
        i = 2
        ngeoms = 32
        ngeoms = <optimized out>
        i = <optimized out>
#1  0x00007fe7051af255 in geos::geom::GeometryFactory::createGeometryCollection (this=this@entry=0x559b487a51c0, newGeoms=newGeoms@entry=0x559b48802180) at GeometryFactory.cpp:416
No locals.
#2  0x00007fe705d6d262 in GEOSGeom_createCollection_r (extHandle=0x559b48786ea0, type=type@entry=7, geoms=0x559b48844ed8, ngeoms=<optimized out>) at geos_ts_c.cpp:3063
        gf = 0x559b487a51c0
        vgeoms = 0x559b48802180
        g = 0x0
        handle = 0x559b48786ea0
#3  0x00007fe705d630e6 in GEOSGeom_createCollection (type=type@entry=7, geoms=<optimized out>, ngeoms=<optimized out>) at geos_c.cpp:705
No locals.
#4  0x00007fe705da6c4e in pgis_geometry_union_finalfn (fcinfo=0x7ffdcd3e8cf0) at lwgeom_geos.c:631
        state = 0x559b48844e80
        gser_out = 0x0
        g = 0x0
        g_union = 0x0
        __func__ = "pgis_geometry_union_finalfn"
#5  0x0000559b47efa0cb in finalize_aggregate (aggstate=aggstate@entry=0x559b487a9e20, peragg=peragg@entry=0x559b487db9f8, resultVal=resultVal@entry=0x559b487dbaf0, resultIsNull=resultIsNull@entry=0x559b487dbb10 "", pergroupstate=<optimized out>, pergroupstate=<optimized out>) at nodeAgg.c:1592
        numFinalArgs = <optimized out>
        fcinfo = {flinfo = 0x559b487dba08, context = 0x559b487a9e20, resultinfo = 0x0, fncollation = 0, isnull = 0 '\000', nargs = 1, arg = {94125424922240, 0, 0, 94125424682912, 0, 140630199842754, 13641340179549726627, 13641340179549726627, 4716133919349538816, 4716133919349538816, 0, 94125424648480, 140630200771528, 94125424648496, 94125424622384, 140630199834314, 4716133919349538816, 9194493494814272512, 4716133919349538816, 94125424143296, 94125424143352, 94125424141472, 256, 94125417708966, 1, 128, 8192, 513, 18446744073709551536, 140630365650072, 65536, 1, 24, 0, 7, 32, 2, 94125423194128, 15, 64, 18446744073709551536, 0, 64, 140630199799886, 7, 94125424713568, 94125424713592, 140630199863426, 63, 112, 18446744073709551536, 1, 210453397509, 0, 0, 511101108315, 0, 532575944814, 2, 63, 64, 3, 18446744073709551536, 94125424144032, 140728046882704, 140630365656611, 140630200766512, 94125424713568, 94125424648480, 94125424648544, 94125424267712, 94125424144032, 94125424417656, 94125424417856, 672, 9194493494814272512, 94125424648544, 94125424140928, 0, 94125424140992, 94125424291848, 94125424288984, 94125424480992, 94125417707196, 94125424481104, 94125417708966, 94125424481104, 94125424065600, 94125424140992, 140630212429432, 94125424481104, 140728046882864, 94125424481104, 140728046882864, 94125424289264, 94125415154335, 94125424499744, 94125424291784, 140728046882928, 94125424961216}, argnull = "\000\000\000\000\000\000\000\000\246=\026H\233U\000\000\300\346\204H\233U\000\000x\037\201H\233U\000\000\021\017\000\000\000\000\000\000\030p\332\005\347\177\000\000\260\224zH\233U\000\000\333\372\360G\233U\000\000\212\001\000\000\233U\000\000\360\245zH\233U\000\000(\260zH\233U\000\000p\247zH\233U\000\000\210\250zH"}
        anynull = <optimized out>
        oldContext = <optimized out>
        i = <optimized out>
        lc = <optimized out>
        pertrans = <optimized out>
#6  0x0000559b47efa57c in finalize_aggregates (aggstate=aggstate@entry=0x559b487a9e20, peraggs=peraggs@entry=0x559b487db9f8, pergroup=<optimized out>) at nodeAgg.c:1799
        peragg = 0x559b487db9f8
        transno = <optimized out>
        pergroupstate = <optimized out>
        econtext = <optimized out>
        aggvalues = <optimized out>
        aggnulls = <optimized out>
        aggno = 0
        transno = <optimized out>
#7  0x0000559b47efb87a in agg_retrieve_direct (aggstate=0x559b487a9e20) at nodeAgg.c:2505
        tmpcontext = 0x559b487aa058
        peragg = 0x559b487db9f8
        hash_pergroups = <optimized out>
        outerslot = <optimized out>
        i = <optimized out>
        firstSlot = 0x559b487aa298
        result = <optimized out>
        hasGroupingSets = 0 '\000'
        numGroupingSets = 1
        currentSet = <optimized out>
        numReset = <optimized out>
        node = 0x559b487b8030
        econtext = 0x559b487aa1d8
        pergroup = 0x559b487dcb48
        nextSetSize = <optimized out>
        node = <optimized out>
        econtext = <optimized out>
        tmpcontext = <optimized out>
        peragg = <optimized out>
        pergroup = <optimized out>
        hash_pergroups = <optimized out>
        outerslot = <optimized out>
        firstSlot = <optimized out>
        result = <optimized out>
        hasGroupingSets = <optimized out>
        numGroupingSets = <optimized out>
        currentSet = <optimized out>
        nextSetSize = <optimized out>
        numReset = <optimized out>
        i = <optimized out>
#8  ExecAgg (pstate=0x559b487a9e20) at nodeAgg.c:2158
        node = 0x559b487a9e20
        result = 0x0
#9  0x0000559b47eecb4d in ExecProcNode (node=0x559b487a9e20) at ../../../src/include/executor/executor.h:250
No locals.
#10 ExecutePlan (execute_once=<optimized out>, dest=0x559b487bbb10, direction=<optimized out>, numberTuples=0, sendTuples=<optimized out>, operation=CMD_SELECT, use_parallel_mode=<optimized out>, planstate=0x559b487a9e20, estate=0x559b487a9260) at execMain.c:1723
        slot = <optimized out>
        current_tuple_count = 0
        slot = <optimized out>
        current_tuple_count = <optimized out>
#11 standard_ExecutorRun (queryDesc=0x559b486c8180, direction=<optimized out>, count=0, execute_once=<optimized out>) at execMain.c:364
        estate = 0x559b487a9260
        operation = CMD_SELECT
        dest = 0x559b487bbb10
        sendTuples = <optimized out>
        oldcontext = 0x559b486d9ed0
        __func__ = "standard_ExecutorRun"
#12 0x0000559b48037e6b in PortalRunSelect (portal=0x559b487c72c0, forward=<optimized out>, count=0, dest=<optimized out>) at pquery.c:932
        queryDesc = 0x559b486c8180
        direction = <optimized out>
        nprocessed = <optimized out>
        __func__ = "PortalRunSelect"
#13 0x0000559b480394d8 in PortalRun (portal=portal@entry=0x559b487c72c0, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=1 '\001', run_once=run_once@entry=1 '\001', dest=dest@entry=0x559b487bbb10, altdest=altdest@entry=0x559b487bbb10, completionTag=0x7ffdcd3e9460 "") at pquery.c:773
        save_exception_stack = 0x7ffdcd3e9710
        save_context_stack = 0x0
        local_sigjmp_buf = {{__jmpbuf = {0, -1491573552534279655, 94125423641592, 140728046883936, 94125424407232, 2, -4647196651462350311, -1491574116205614567}, __mask_was_saved = 0, __saved_mask = {__val = {94125419562501, 94124208291841, 140727420601965, 94124208291840, 94125423631512, 0, 94125423631360, 94125419562501, 4, 1, 4, 140728046883934, 88, 94125424407232, 94125423641592, 94125419014460}}}}
        result = <optimized out>
        nprocessed = <optimized out>
        saveTopTransactionResourceOwner = 0x559b486d45a0
        saveTopTransactionContext = 0x559b486d4850
        saveActivePortal = 0x0
        saveResourceOwner = 0x559b486d45a0
        savePortalContext = 0x0
        saveMemoryContext = 0x559b486d4850
        __func__ = "PortalRun"
#14 0x0000559b480351b1 in exec_simple_query (query_string=0x559b487259b0 "with inverted_geom as (\n    select ST_Difference(\n", ' ' <repeats 15 times>, "ST_Expand('SRID=3857;POINT(0 0)' :: geometry, 20000000),\n", ' ' <repeats 15 times>, "ST_Buffer(\n", ' ' <repeats 19 times>, "'SRID=3857;POINT(0 0)' :: geometr"...) at postgres.c:1122
        parsetree = 0x559b4870c3c0
        portal = 0x559b487c72c0
        snapshot_set = <optimized out>
        commandTag = <optimized out>
        completionTag = "\000\000\000\000\002\000\000\000Q\000\000\000\000\000\000\000\260\224>\315\375\177\000\000\360\225>\315\375\177\000\000\260YrH\233U\000\000\200!jH\233U\000\000\000\000\000\000\000\000\000\000\320\001mH\233U\000"
        querytree_list = <optimized out>
        plantree_list = <optimized out>
        receiver = 0x559b487bbb10
        format = 0
        dest = DestRemote
        oldcontext = 0x559b486d4850
        parsetree_list = 0x559b4870c420
        parsetree_item = 0x559b4870c3f8
        save_log_statement_stats = 0 '\000'
        was_logged = 0 '\000'
        isTopLevel = 1 '\001'
        msec_str = "\000\000\000\000\002\000\000\000Q\000\000\000\000\000\000\000\260\224>\315\375\177\000\000\360\225>\315\375\177\000"
        __func__ = "exec_simple_query"
#15 0x0000559b480368e2 in PostgresMain (argc=<optimized out>, argv=argv@entry=0x559b486d01d0, dbname=<optimized out>, username=<optimized out>) at postgres.c:4117
        query_string = 0x559b487259b0 "with inverted_geom as (\n    select ST_Difference(\n", ' ' <repeats 15 times>, "ST_Expand('SRID=3857;POINT(0 0)' :: geometry, 20000000),\n", ' ' <repeats 15 times>, "ST_Buffer(\n", ' ' <repeats 19 times>, "'SRID=3857;POINT(0 0)' :: geometr"...
        firstchar = <optimized out>
        input_message = {data = 0x559b487259b0 "with inverted_geom as (\n    select ST_Difference(\n", ' ' <repeats 15 times>, "ST_Expand('SRID=3857;POINT(0 0)' :: geometry, 20000000),\n", ' ' <repeats 15 times>, "ST_Buffer(\n", ' ' <repeats 19 times>, "'SRID=3857;POINT(0 0)' :: geometr"..., len = 439, maxlen = 1024, cursor = 439}
        local_sigjmp_buf = {{__jmpbuf = {140728046884368, 4646110874158869017, 94125423206784, 140728046884928, 94125423395280, 94125420647040, -4647196651388949991, -1491574109633795559}, __mask_was_saved = 1, __saved_mask = {__val = {0, 94125423395208, 1024, 140728046884800, 140728046884928, 94125423395280, 94125417734909, 0, 94125417708966, 94125420647040, 140728046884800, 140728046884928, 94125417623520, 94125423333184, 4398046511104, 0}}}}
        send_ready_for_query = 0 '\000'
        disable_idle_in_transaction_timeout = 0 '\000'
        __func__ = "PostgresMain"
#16 0x0000559b47fbb497 in BackendRun (port=0x559b486c9530) at postmaster.c:4406
        ac = 1
        secs = 609109337
        usecs = 382752
        i = 1
        av = 0x559b486d01d0
        maxac = <optimized out>
        av = <optimized out>
        maxac = <optimized out>
        ac = <optimized out>
        secs = <optimized out>
        usecs = <optimized out>
        i = <optimized out>
        __func__ = "BackendRun"
#17 BackendStartup (port=0x559b486c9530) at postmaster.c:4078
        bn = <optimized out>
        pid = <optimized out>
        bn = <optimized out>
        pid = <optimized out>
        __func__ = "BackendStartup"
        save_errno = <optimized out>
#18 ServerLoop () at postmaster.c:1756
        port = 0x559b486c9530
        i = <optimized out>
        rmask = {fds_bits = {32, 0 <repeats 15 times>}}
        selres = <optimized out>
        now = <optimized out>
        readmask = {fds_bits = {56, 0 <repeats 15 times>}}
        nSockets = 6
        last_lockfile_recheck_time = <optimized out>
        last_touch_time = 1555793903
        __func__ = "ServerLoop"
#19 0x0000559b47fbc33c in PostmasterMain (argc=3, argv=0x559b4869ffd0) at postmaster.c:1364
        opt = <optimized out>
        status = <optimized out>
        userDoption = <optimized out>
        listen_addr_saved = <optimized out>
        i = <optimized out>
        output_config_variable = <optimized out>
        __func__ = "PostmasterMain"
#20 0x0000559b47d3fd86 in main (argc=3, argv=0x559b4869ffd0) at main.c:228
No locals.

Change History (8)

comment:1 Changed 7 months ago by dbaston

What is the failing geometry? Is there an associated GEOS ticket?

comment:2 Changed 7 months ago by dbaston

Milestone: PostGIS GEOSPostGIS 3.0.0

Seems more likely related to r17398

comment:3 Changed 7 months ago by komzpa

In 17403:

Reallocate Union state in aggregate context.

References #4382

comment:4 Changed 7 months ago by komzpa

In 17404:

Satisfy ISO C90.
References #4382

comment:5 Changed 7 months ago by komzpa

In 17405:

Call POSTGIS2GEOS in aggregate context.

References #4382

comment:6 Changed 7 months ago by komzpa

In 17406:

ST_Union: allocate correct size of memory in right context

Thanks Raul for finding the cause.

References #4382
Closes https://github.com/postgis/postgis/pull/397

comment:7 Changed 7 months ago by dbaston

The repalloc call that I pointed out to you needs to be in the side memory context because it is allocating memory using palloc that needs to survive until the finalizer, but I'm pretty sure the POSTGIS2GEOS call does not.

comment:8 Changed 5 months ago by Algunenano

Resolution: fixed
Status: newclosed

This was fixed in r17406

Note: See TracTickets for help on using tickets.