Opened 8 years ago

Closed 8 years ago

#3583 closed defect (fixed)

Server crashes when running particular ST_GeomFromJSON command

Reported by: bmmpxf Owned by: pramsey
Priority: medium Milestone: PostGIS 2.1.9
Component: postgis Version: 2.1.x
Keywords: Cc:

Description

Hi. In pgAdmin (or psql), running the following command:

Select ST_GeomFromGeoJSON('{"type":"MultiPolygon", "coordinates":[139.10030364990232,35.16777444430609],5842.4224490305424}');

The Postgres service immediately shuts down. I've never seen this sudden behavior before.

Log file shows:

LOG:  server process (PID 9576) was terminated by exception 0xC0000005
DETAIL:  Failed process was running: select ST_GeomFromGeoJSON('{"type":"MultiPolygon", "coordinates":[[[139.10030364990232,35.16777444430609],5842.4224490305424]]}'); 
HINT:  See C include file "ntstatus.h" for a description of the hexadecimal value.

According to Microsoft, exception 0xC0000005 means "STATUS_ACCESS_VIOLATION": "The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could not be %s."

https://msdn.microsoft.com/en-us/library/cc704588.aspx

Tested on PostGIS 2.1.7 and Postgres 9.3 on Windows 10 and Windows Server 2012.

Any ideas?

Change History (11)

comment:1 by bmmpxf, 8 years ago

Better formatting:

Select ST_GeomFromGeoJSON('{"type":"MultiPolygon", "coordinates":[[[139.10030364990232,35.16777444430609],5842.4224490305424]]}'); 

comment:2 by pramsey, 8 years ago

Huh, doesn't crash on 2.2, but my 2.1 it does. Usually it's a consistent crash back to 2.0 since the code's pretty in sync. Will debug and get back to you.

comment:3 by pramsey, 8 years ago

Resolution: fixed
Status: newclosed

Looks like it was mis-fixed during a prior cleanup. All the other versions got the right code, but 2.1 got a bad copy/paste.

Fixed at r14970 in 2.1 branch. Putting this example into a ticket regress in trunk just for giggles.

comment:4 by bmmpxf, 8 years ago

Thanks pramsey! Glad it was an easy fix.

comment:5 by bmmpxf, 8 years ago

Resolution: fixed
Status: closedreopened

Would the fix for this issue fix a similar crash situation, but with an empty JSON string?

select ST_GeomFromGeoJSON('{"type":"MultiPolygon", "coordinates":[[]]}');

Or is this a different issue? The behavior is the same.

comment:6 by pramsey, 8 years ago

Works for me, so yes, the patch fixed your new example as well.

comment:7 by robe, 8 years ago

This seems to have broken the 2.1 bot builds (I see red flags everywhere).

On debbie I'm seeing:

 tickets .. failed (diff expected obtained: /var/lib/jenkins/workspace/postgis/tmp/2_1_pg9.4w64/test_72_diff)
-----------------------------------------------------------------------------
--- tickets_expected	2016-06-17 22:20:25.701852538 +0000
+++ /var/lib/jenkins/workspace/postgis/tmp/2_1_pg9.4w64/test_72_out	2016-06-17 22:22:08.653858614 +0000
@@ -188,7 +188,6 @@
 #745|GEOMETRYCOLLECTION(POLYGON((-72 42 1,-70 43 1,-71 41 1,-72 42 1)))
 #1450|POINT|POLYGON
 #1482|4326
-COPY 2
 #852.1|1|f|f
 #852.1|2|f|f
 #852.2|1|t|t
-----------------------------------------------------------------------------

I suspect we may be stripping things out like COPY lines, since they are inconsistent depending on PostgreSQL version, so might just require taking that out.

comment:8 by pramsey, 8 years ago

Yeah, that got in there from me running ./run_test —expect to generate a new file… maybe the generator needs a little polish

comment:9 by robe, 8 years ago

Great. Is there a reason we still have this ticket open?

comment:10 by bmmpxf, 8 years ago

I reopened the ticket just to verify that the second case was being addressed. It sounds like it is, so I have no objection to the ticket being closed if no one else does. Thanks for the help all.

comment:11 by robe, 8 years ago

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