Opened 4 years ago

Closed 4 years ago

#4699 closed defect (fixed)

crash on null input to ST_Union(raster, otherarg)

Reported by: jcasanov Owned by: robe
Priority: medium Milestone: PostGIS 2.4.9
Component: raster Version: 2.5.x -- EOL
Keywords: st_union raster null Cc: jcasanov

Description

st_union() crash in any of the more-than-one argument variant.

select st_union(null::raster); — does not fail select st_union(null::raster, 1); — crash the server

attached is the backtrace of the query that crash, showed above

postgres version


PostgreSQL 12.3 (Debian 12.3-1.pgdg100+1) on x86_64-pc-linux-gnu,

compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit

postgis full version


POSTGIS="2.5.4" [EXTENSION] PGSQL="120" GEOS="3.7.1-CAPI-1.11.1

27a5e771" PROJ="Rel. 5.2.0, September 15th, 2018" GDAL="GDAL 2.4.0, released 2018/12/14" LIBXML="2.9.4" LIBJSON="0.12.1" LIBPROTOBUF="1.3.1" RASTER

Attachments (1)

stack_trace_st_union_null_crash.txt (11.7 KB ) - added by jcasanov 4 years ago.
stack trace of the crash

Download all attachments as: .zip

Change History (12)

by jcasanov, 4 years ago

stack trace of the crash

comment:1 by jcasanov, 4 years ago

This patch fixes the problem for me

diff --git a/raster/rt_pg/rtpg_mapalgebra.c b/raster/rt_pg/rtpg_mapalgebra.c
index b3b6323cb..33ec63a80 100644
--- a/raster/rt_pg/rtpg_mapalgebra.c
+++ b/raster/rt_pg/rtpg_mapalgebra.c
@@ -2896,8 +2896,11 @@ Datum RASTER_union_finalfn(PG_FUNCTION_ARGS)
 				PG_RETURN_NULL();
 			}
 		}
-		else
+		else {
 			_raster = iwr->bandarg[i].raster[0];
+			if (_raster == NULL)
+				continue;
+		}
 
 		/* first band, _rtn doesn't exist */
 		if (i < 1) {
Last edited 4 years ago by jcasanov (previous) (diff)

comment:2 by jcasanov, 4 years ago

Cc: jcasanov added

comment:3 by robe, 4 years ago

jcasanov,

Thanks for the patch. I'll try to check it out today.

comment:4 by robe, 4 years ago

Owner: changed from Bborie Park to robe

comment:5 by Regina Obe <lr@…>, 4 years ago

In b163027/git:

Fix for raster crash. References #4699 - Jaime Casanova (2nd Quadrant)

comment:6 by robe, 4 years ago

Milestone: PostGIS 2.4.9

comment:7 by Regina Obe <lr@…>, 4 years ago

In f70a085/git:

Fix bug fix notice references #4699

comment:8 by Regina Obe <lr@…>, 4 years ago

In 43fd77f/git:

Fix for raster crash. References #4699 for 3.0.2 - Jaime Casanova (2nd Quadrant)

comment:9 by Regina Obe <lr@…>, 4 years ago

In ce30368/git:

Fix for raster crash. References #4699 for 2.5.5 - Jaime Casanova (2nd Quadrant)

comment:10 by Regina Obe <lr@…>, 4 years ago

In 2cec61e/git:

Fix for raster crash. References #4699 for 2.4.9 - Jaime Casanova (2nd Quadrant)

comment:11 by robe, 4 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.