Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#4724 closed defect (fixed)

[raster] crash on null input to st_summarystatsagg()

Reported by: Robins Owned by: robe
Priority: medium Milestone: PostGIS 3.0.4
Component: raster Version: 3.0.x
Keywords: st_summarystatsagg null Cc:

Description

Brief When st_summarystatsagg() is called with NULLs it crashes the server.

Repro

select public.st_summarystatsagg(NULL::raster, NULL::int4, NULL::bool) over (order by q) from generate_series(1,2) as e(q);


SQL Output

db=> SELECT postgis_full_version();
                                                                                                            postgis_full_version

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------
 POSTGIS="3.0.0 r17983" [EXTENSION] PGSQL="120" GEOS="3.8.0-CAPI-1.13.1 " PROJ="Rel. 5.2.0, September 15th, 2018" GDAL="GDAL 2.4.4, released 2020/01/08" LIBXML="2.9.1" LIBJSON="0.13.1" LIBP
ROTOBUF="1.3.2" WAGYU="0.4.3 (Internal)" RASTER
(1 row)

db=> select version();
                                                 version
---------------------------------------------------------------------------------------------------------
 PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11), 64-bit
(1 row)

db=> \dx
                                        List of installed extensions
      Name      | Version |   Schema   |                             Description
----------------+---------+------------+---------------------------------------------------------------------
 plpgsql        | 1.0     | pg_catalog | PL/pgSQL procedural language
 postgis        | 3.0.0   | public     | PostGIS geometry, geography, and raster spatial types and functions
 postgis_raster | 3.0.0   | public     | PostGIS raster types and functions
(3 rows)


db=> select public.st_summarystatsagg(NULL::raster, NULL::int4, NULL::bool) over (order by q) from generate_series(1,2) as e(q);
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.
!?>

Change History (11)

comment:1 by robe, 3 years ago

Owner: changed from Bborie Park to robe

comment:2 by robe, 3 years ago

Milestone: PostGIS 3.1.0PostGIS 3.0.4

Going to push this to 3.0.4 to move out of 3.1.0 way and also since I think it is an issue in 3.0.4 too so should be fixed there as well.

comment:3 by Robins, 3 years ago

2 other Tickets, with similar (WINDOW PARTITION) crashes… may be they're related.

comment:4 by robe, 3 years ago

backtrace:

Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) cont
Continuing.
[Thread 11716.0x495c exited with code 0]

Thread 1 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 11716.0x5b98]
0x000000006e3a7372 in RASTER_summaryStats_finalfn (fcinfo=0x520e9a0)
    at rtpg_statistics.c:854
854             if (state->stats->count > 0) {

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

In 04f4524/git:

Fix summaryagg window crash - references #4724 for PostGIS 3.1.3

comment:6 by robe, 3 years ago

I think I'm going to revert my change. I thought it fixed the issue but looks like simply putting an OVER(random()) on some of the other test queries still crashes the backend.

So I think this requires a bit more thought. A lot of the raster have the same function when a window clause is applied and I need to test window aggs in our garden teststo see which others are affected.

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

In 7ced53e/git:

Revert last commit. References #4724

comment:8 by Paul Ramsey <pramsey@…>, 3 years ago

In ef2995b/git:

Fix crashes in aggregate functions, references #4916, #4770, #4724, #4916

comment:9 by Paul Ramsey <pramsey@…>, 3 years ago

In 22dec99/git:

Fix crashes in aggregate functions, references #4916, #4770, #4724, #4916

comment:10 by pramsey, 3 years ago

Resolution: fixed
Status: newclosed

comment:11 by Paul Ramsey <pramsey@…>, 3 years ago

In 5548ad23/git:

Repair crashes in raster aggregates, references #4916, #4770, #4724, #4916

Note: See TracTickets for help on using tickets.