Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#4331 closed defect (fixed)

ST_3DMakeBox crashes on POINT EMPTY

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

Description

Tested on

POSTGIS="3.0.0dev r17279" [EXTENSION] PGSQL="120" GEOS="3.8.0dev-CAPI-1.11.0 a47cf0f5" SFCGAL="1.3.2" PROJ="Rel. 5.2.0, September 15th, 2018" GDAL="GDAL 2.3.1, released 2018/06/22" LIBXML="2.7.8" LIBPROTOBUF="1.2.1" RASTER PostgreSQL 12develslicing on x86_64-w64-mingw32, compiled by gcc.exe (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0, 64-bit

and

POSTGIS="3.0.0dev r17265" [EXTENSION] PGSQL="110" GEOS="3.8.0dev-CAPI-1.11.0 a47cf0f5" PROJ="Rel. 5.2.0, September 15th, 2018" LIBXML="2.7.8" LIBPROTOBUF="1.2.1" PostgreSQL 11.0 on x86_64-w64-mingw32, compiled by gcc.exe (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0, 64-bit
 SELECT ST_3DMakeBox(ST_GeomFromText('POINT EMPTY',4326), ST_GeomFromText('POINT EMPTY',4326))

I couldn't get a back trace for some reason. Just gives:

[Thread 9816.0x99c exited with code 0]
[Thread 9816.0x3090 exited with code 3]
[Thread 9816.0xd1c exited with code 3]
[Inferior 1 (process 9816) exited with code 03]

PostGIS 2.5.1 is fine and gives:

BOX3D(0 2.61511713111389e-317 5.59388634019276e-317,5.59390215029343e-317 3.47323850655278e-317 5.59386657756693e-317)

I think i had run garden tests earlier in 3.0 cycle so this might be a relatively new issue in 3.0. Last time I tried running the tests I think a month or so it would hange becasue of thge GEOS 3.8 issue I was having under mingw64.

Change History (7)

comment:1 by komzpa, 5 years ago

posted case to Travis, let's see if it brings back a trace: https://github.com/postgis/postgis/pull/376

comment:2 by Algunenano, 5 years ago

This works fine in 12593.f4cdc57bc and crashes in 12604.b608efe32:

#0  0x00007f36f88fcd7f in raise () from /usr/lib/libc.so.6
#1  0x00007f36f88e7672 in abort () from /usr/lib/libc.so.6
#2  0x00007f36f88e7548 in __assert_fail_base.cold.0 () from /usr/lib/libc.so.6
#3  0x00007f36f88f5396 in __assert_fail () from /usr/lib/libc.so.6
#4  0x00007f34e8095e8e in getPoint3dz_p (pa=<optimized out>, n=0, op=<optimized out>) at /usr/src/debug/postgis/liblwgeom/lwgeom_api.c:222
#5  BOX3D_construct (fcinfo=<optimized out>) at lwgeom_box3d.c:570
#6  0x000055e6cf6523e0 in ExecInterpExpr (state=<optimized out>, econtext=<optimized out>, isnull=0x7ffe49cff5df) at execExprInterp.c:678
#7  0x000055e6cf71e5ae in ExecEvalExprSwitchContext (state=<optimized out>, econtext=0x7ffe49cff1c0, isNull=0x50e7494944bc0000)
    at ../../../../src/include/executor/executor.h:303
#8  evaluate_expr (expr=<optimized out>, result_type=85661, result_typmod=-1, result_collation=0) at clauses.c:4970
#9  0x000055e6cf71dddf in evaluate_function (funcid=85900, result_type=<optimized out>, result_typmod=-1, result_collid=0, 
    input_collid=0, args=0x55e6d13d9408, context=<optimized out>, funcvariadic=<optimized out>, func_tuple=<optimized out>)

I can bisect it to a specific commit if necessary

comment:3 by komzpa, 5 years ago

It's this assert I left when debugging 3D intersection:

https://github.com/postgis/postgis/blob/3abc9a25c3f2c03d0adf24fb96b65336493bb170/liblwgeom/lwgeom_api.c#L222

We can blindly pull out this assert, or we can do something to make the out-of-bounds access not happen in EMPTY. Does a 3DMakeBox make sense on top of two empty points? What is really expected in this case?

comment:4 by Algunenano, 5 years ago

Does a 3DMakeBox make sense on top of two empty points? What is really expected in this case?

ST_MakeBox2D returns an error (which isn't very clear BTW), so I'd match that behaviour:

SELECT ST_MakeBox2D(ST_GeomFromText('POINT EMPTY',4326), ST_GeomFromText('POINT EMPTY',4326))
;
ERROR:  lwpoint_get_x called with empty geometry

comment:5 by robe, 5 years ago

Nothing makes sense on top of 2 empty points. Yah I'd go with just throwing an error. It makes more sense to make a box from a real point and a real linestring than it does to do so with 2 point empties and those return errors, so this should too.

Well at least the 2d does tell you you gave it a point empty which is clear to me.

comment:6 by robe, 5 years ago

Resolution: fixed
Status: newclosed

In 17281:

Get rid of assert causing ST_3DMakeBox to crash
Change ST_3DMakeBox to throw an error when fed empty points instead of returning a philosophical answer to a stupid question
Change ST_MakeBox2D to return a more meaningful error instead waiting to fail when asking what is x of an empty point?
Closes #4331 for PostGIS 3.0

comment:7 by robe, 5 years ago

In 17282:

oops didn't notice was LWPOINT and not LWGEOMGet rid of assert causing ST_3DMakeBox to crash
References #4331 for PostGIS 3.0

Note: See TracTickets for help on using tickets.