Opened 4 years ago

Closed 4 years ago

#4722 closed defect (fixed)

crash on null input to topogeo_addpoint()

Reported by: robins Owned by: strk
Priority: medium Milestone: PostGIS 3.1.0
Component: topology Version: 3.0.x
Keywords: topogeo_addpoint Cc:

Description

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

Sample SQLs:

SELECT topogeo_addpoint(null::varchar, null::geometry, NULL::float8);
SELECT topogeo_addpoint(cast(null as "varchar"),cast(null as geometry),cast(NULL as float8));


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" LIBXML="2.9.1" LIBJSON="0.13.1" LIBPROTOBUF="1.3.2" WAGYU="0.4.3 (Internal)" TOPOLOGY
(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_topology | 3.0.0   | topology   | PostGIS topology spatial types and functions
(3 rows)

db=> SELECT topogeo_addpoint(cast(null as "varchar"),cast(null as geometry),cast(NULL as float8));
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.
!?> \q
~$ psql db
psql (13beta2, server 12.3)
Type "help" for help.

db=>


Error Logs

2020-07-15 02:35:32 UTC::@:[23172]:LOG:  server process (PID 27631) was terminated by signal 11: Segmentation fault
2020-07-15 02:35:32 UTC::@:[23172]:DETAIL:  Failed process was running: SELECT topogeo_addpoint(cast(null as "varchar"),cast(null as geometry),cast(NULL as float8));
2020-07-15 02:35:32 UTC::@:[23172]:LOG:  terminating any other active server processes
2020-07-15 02:35:32 UTC::@:[26751]:WARNING:  terminating connection because of crash of another server process
2020-07-15 02:35:32 UTC::@:[26751]:DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2020-07-15 02:35:32 UTC::@:[26751]:HINT:  In a moment you should be able to reconnect to the database and repeat your command.
2020-07-15 02:35:32 UTC::@:[23172]:LOG:  archiver process (PID 26752) exited with exit code 1
2020-07-15 02:35:32 UTC:172.31.7.235(45906):postgres123@db:[28053]:FATAL:  the database system is in recovery mode
2020-07-15 02:35:32 UTC::@:[23172]:LOG:  all server processes terminated; reinitializing
2020-07-15 02:35:32 UTC::@:[28054]:LOG:  database system was interrupted; last known up at 2020-07-15 02:33:29 UTC
2020-07-15 02:35:32 UTC::@:[28054]:LOG:  database system was not properly shut down; automatic recovery in progress
2020-07-15 02:35:32 UTC::@:[28054]:LOG:  redo starts at 36/55478720
2020-07-15 02:35:32 UTC::@:[28054]:LOG:  invalid record length at 36/554E6F18: wanted 24, got 0
2020-07-15 02:35:32 UTC::@:[28054]:LOG:  redo done at 36/554E5170
2020-07-15 02:35:32 UTC::@:[28054]:LOG:  checkpoint starting: end-of-recovery immediate
2020-07-15 02:35:32 UTC::@:[28054]:LOG:  checkpoint complete: wrote 62 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.003 s, sync=0.002 s, total=0.015 s; sync files=13, longest=0.002 s, average=0.000 s; distance=442 kB, estimate=442 kB
2020-07-15 02:35:32 UTC::@:[23172]:LOG:  database system is ready to accept connections

Change History (4)

comment:1 by Sandro Santilli <strk@…>, 4 years ago

In f0b631a/git:

Fix crash on TopoGeo_addPoint null arguments

References #4722 in master branch (3.1.0dev)

comment:2 by Sandro Santilli <strk@…>, 4 years ago

In 41d75a1/git:

Fix crash on TopoGeo_addPoint null arguments

References #4722 in master 3.0 branch (3.0.2dev)

comment:3 by Sandro Santilli <strk@…>, 4 years ago

In 9be75d1/git:

Fix crash on TopoGeo_addPoint null arguments

References #4722 in 2.5 branch (2.5.5dev)

comment:4 by Sandro Santilli <strk@…>, 4 years ago

Resolution: fixed
Status: newclosed

In c62c93f/git:

Fix crash on TopoGeo_addPoint null arguments

Closes #4722 in 2.4 branch (2.4.9dev)

Note: See TracTickets for help on using tickets.