#668 closed defect (invalid)

Union crashes when there are EMPTY items inside MULTI- or GEOMETRYCOLLECTION objects

Reported by: otan Owned by: osgeo4w-dev@…
Priority: minor Component: Package
Version: Keywords:
Cc:

Description

Found this using CockroachDB's randomised syntax generator. This crashes on postgres too, I can write a more GEOS specific repro if desired.

psql (13.2)
Type "help" for help.
otan=# select PostGIS_GEOS_Version();
 postgis_geos_version
----------------------
 3.9.1-CAPI-1.14.2
(1 row)

otan=# select st_union('POLYGON Z ((-8576813007.651572 -932867148.5664893 -594332188.2168996, -9076378702.816006 -1058770692.353365 -2286612467.79976, -8577214214.487094 -923078893.7098079 -922845555.2543786, -8763948942.517227 3632693707.16387 -1890400776.3303413, -7612818442.454826 3813396489.705141 -376275881.4206352, -4258868082.9764023 2821219037.959036 -7927470779.677084, -2376927148.576969 762393778.6277254 -5185416958.8125515, 8374297972.826973 3684983643.201231 -3159751777.281743, -2311638561.4350195 690968693.0169502 -2246826599.5283184, 3511882417.12018 -5679907177.601899 -7190612231.893617, -8305726872.755655 -7546563480.596777 3891638858.362171, -8576813007.651572 -932867148.5664893 -594332188.2168996))', ' GEOMETRYCOLLECTION ZM (MULTIPOINT ZM (-572200857.2088509 7909820002.898613 -5497698646.885041 6664440051.466028, -429525248.49892807 9279013845.258144 1865812608.4202595 -5627983850.52976, -8961875736.194313 -3646093887.306757 6114061050.084791 7928242422.52462, -1658395500.6136656 5463281975.551853 1226372454.8883152 -6033337335.334749, EMPTY), LINESTRING ZM (5640013450.60927 -4034194887.4798727 7233778169.767132 -8214889161.72134, 9862309549.538734 5014594919.08839 -925144949.3365879 -5659691769.45695), MULTIPOLYGON ZM EMPTY, MULTIPOINT ZM (EMPTY, 4481472784.121752 -8278911850.336457 6955040725.022459 4792703658.978086, EMPTY))');
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.
!?>

Cross reference https://github.com/cockroachdb/cockroach/issues/62184

Change History (5)

comment:1 by jef, 15 months ago

Resolution: invalid
Status: newclosed

Looks like a PostGIS/PostgreSQL issue to me. OSGeo4W just has libpq&psql.

comment:2 by otan, 15 months ago

This is a GEOS issue. Here is a GEOS repro (using intersects, which AFAICT union calls).

 ✘ ⚙ otan@otan-mbp  ~   g++ -o tst tst.cc -lgeos -lgeos_c -std=c++11
 ⚙ otan@otan-mbp  ~  ./tst
[3]    86414 segmentation fault  ./tst
 ✘ ⚙ otan@otan-mbp  ~  cat tst.cc
#include <geos_c.h>
#include <string>

using namespace std;

void geos_message_handler(const char *fmt, ...) {}
void geos_error_handler(const char *fmt, ...) {}

int main() {
  // POLYGON Z ((-8576813007.651572 -932867148.5664893 -594332188.2168996, -9076378702.816006 -1058770692.353365 -2286612467.79976, -8577214214.487094 -923078893.7098079 -922845555.2543786, -8763948942.517227 3632693707.16387 -1890400776.3303413, -7612818442.454826 3813396489.705141 -376275881.4206352, -4258868082.9764023 2821219037.959036 -7927470779.677084, -2376927148.576969 762393778.6277254 -5185416958.8125515, 8374297972.826973 3684983643.201231 -3159751777.281743, -2311638561.4350195 690968693.0169502 -2246826599.5283184, 3511882417.12018 -5679907177.601899 -7190612231.893617, -8305726872.755655 -7546563480.596777 3891638858.362171, -8576813007.651572 -932867148.5664893 -594332188.2168996))
  string aEWKB = "0103000080010000000C000000D76CFA7C7CF3FFC1B982482636CDCBC15EC31B0E65B6C1C12E877662F4E700C2103B2D82C78DCFC1A29779FE5D09E1C123CB6770DEF3FFC1FCDADA768882CBC17A8FA0B9C080CBC1482374FCF95200C26C3E6539D010EB41502415824E2BDCC1F846A740265CFCC1849036017A69EC41C0AE6BA9836DB6C1B03E5F6E25BBEFC16CB0BE5B0C05E54156D5BAAB3988FDC1887692F5A0B5E1C14E5950599AB8C6413600EDEF3251F3C1483B4D575A32FF417C70666B8C74EB410A04298CBF8AE7C1AEEB2DC41939E1C16D2B823AAC97C441FCE7F04C7BBDE0C184D82356622AEA4161A19916C828F5C1414C7E9080C9FAC12A178C59F5F0FEC1668C89B9F61CFCC1E8964B49B6FEEC41D76CFA7C7CF3FFC1B982482636CDCBC15EC31B0E65B6C1C1";
  // GEOMETRYCOLLECTION ZM (MULTIPOINT ZM (-572200857.2088509 7909820002.898613 -5497698646.885041 6664440051.466028, -429525248.49892807 9279013845.258144 1865812608.4202595 -5627983850.52976, -8961875736.194313 -3646093887.306757 6114061050.084791 7928242422.52462, -1658395500.6136656 5463281975.551853 1226372454.8883152 -6033337335.334749, EMPTY), LINESTRING ZM (5640013450.60927 -4034194887.4798727 7233778169.767132 -8214889161.72134, 9862309549.538734 5014594919.08839 -925144949.3365879 -5659691769.45695), MULTIPOLYGON ZM EMPTY, MULTIPOINT ZM (EMPTY, 4481472784.121752 -8278911850.336457 6955040725.022459 4792703658.978086, EMPTY))
  string bEWKB = " 01070000C00400000001040000C00500000001010000C0A0BB9ACC8B0DC1C1B8602E666477FD4121296E95037BF4C1DA74378FB4D3F84101010000C0C0B97F00099AB9C1AE10AA1E9448014288E51AA082CDDB41E679A87E43F7F4C101010000C0F48DC1F85AB100C2F4D0E9475F2AEBC14E5BA1AFD2C6F641D864680FF688FD4101010000C04C4627DB46B6D8C164D47813315AF44128DAB8593D46D241225B75BFD679F6C101010000C0000000000000F87F000000000000F87F000000000000F87F000000000000F87F01020000C00200000092BFA968BC02F5411E5BEFB89D0EEEC12C469C1FABF2FA419C8A9B2C549AFEC1544F6C35B75E02420C6A71564AAEF2415015ABBA4B92CBC1AB4F97AF8015F5C101060000C00000000001040000C00300000001010000C0000000000000F87F000000000000F87F000000000000F87F000000000000F87F01010000C0B2F20191DDB1F0412162A5B662D7FEC1FE5B50FDD7E8F9413EA6AFAAADDAF14101010000C0000000000000F87F000000000000F87F000000000000F87F000000000000F87F";

  initGEOS(&geos_message_handler, &geos_error_handler);

  auto wkbReader = GEOSWKBReader_create();
  auto geomA = GEOSWKBReader_read(wkbReader, reinterpret_cast<const unsigned char*>(aEWKB.data()), aEWKB.length());
  auto geomB = GEOSWKBReader_read(wkbReader, reinterpret_cast<const unsigned char*>(bEWKB.data()), bEWKB.length());
  GEOSIntersects(geomA, geomB);
  return 0;
}

comment:3 by otan, 15 months ago

Resolution: invalid
Status: closedreopened

comment:4 by otan, 15 months ago

ah my bad, i got the wrong link for a ticket. sorry!

comment:5 by jef, 15 months ago

Resolution: invalid
Status: reopenedclosed
Note: See TracTickets for help on using tickets.