Opened 11 years ago

Closed 11 years ago

#2340 closed defect (fixed)

typmod check error crashing when in trigger on windows 64-bit EDB

Reported by: robe Owned by: robe
Priority: critical Milestone: PostGIS 2.1.0
Component: postgis Version: 2.0.x
Keywords: windows64, edb Cc:

Description

The tickets crash noted in #2338 I isolated to:

drop table if exists a ;
SELECT '<#1320>';
CREATE TABLE A ( geom geometry(MultiPolygon, 4326),
                 geog geography(MultiPolygon, 4326) );


CREATE OR REPLACE FUNCTION triga() RETURNS trigger AS
$$ BEGIN
	NEW.geom = ST_GeometryN(New.geom,1);
	NEW.geog = ST_GeometryN(New.geog::geometry,1)::geography;
	RETURN NEW;
END; $$ language plpgsql VOLATILE;
CREATE TRIGGER triga_before
  BEFORE INSERT ON a FOR EACH ROW
  EXECUTE PROCEDURE triga();


-- run these a couple of times
INSERT INTO a(geog) VALUES('SRID=4326;MULTIPOLYGON (((0 0, 10 0, 10 10, 0 0)))'::geography);
INSERT INTO a(geom) VALUES('SRID=4326;MULTIPOLYGON (((0 0, 10 0, 10 10, 0 0)))'::geometry);
-- first time
ERROR: Geometry type (Polygon) does not match column type (MultiPolygon)

-- second time crash

crash Seems to be happening in postgis\gserialized_typmod.c around line 141 in postgis_valid_typmod function:

http://postgis.net/docs/doxygen/2.1/d4/df6/gserialized__typmod_8c_source.html#l00141

I suspect all parts have same issue

this is running on a windows 2008 R2 64bit server

POSTGIS="2.1.0beta3dev r11482" GEOS="3.4.0dev-CAPI-1.8.0 r0" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.10.0, released 2013/04/24" LIBXML="2.7.8" LIBJSON="UNKNOWN" RASTER PostgreSQL 9.2.4, compiled by Visual C++ build 1600, 64-bit

and get similar failure with 2.0.4 branch.

Change History (4)

comment:1 by robe, 11 years ago

actually its only the geom insert that triggers a crash. They go thru the same loop of code though. But I think somehow the casting of geog:geometry is protecting it from crashing. If I put a bogus cast on the geometry one like New.geom::geography::geometry it doesn't crash. Maybe there is something fundamentally wrong with ereport under windows 64 VC++ builds.

comment:2 by robe, 11 years ago

hmm not having any luck getting this to trigger a crash anymore. I don't recall doing anything to fix this. I thought it was maybe my new gcc 4.8 with seh error handling at work, but I swapped back to winnie binaries and on my windows 7 64-bit its fine.

PostgreSQL 9.2.4, compiled by Visual C++ build 1600, 64-bit POSTGIS="2.1.0beta3dev r11540" GEOS="3.4.0dev-CAPI-1.8.0 r0" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.10.0, released 2013/04/24" LIBXML="2.7.8" LIBJSON="UNKNOWN" RASTER

I'll have to check the server — could it be only a windows 2008 r2 64bit. I'll check the other failures

comment:3 by robe, 11 years ago

Keywords: windows64 edb added

comment:4 by robe, 11 years ago

Milestone: PostGIS 2.0.4PostGIS 2.1.0
Resolution: fixed
Status: newclosed

similar issue but I can't repeatedly even replicate this problem. Should be a nono-issue for 9.3 users. 9.2 users may suffer and we'll just encourage them to upgrade which will make PostgreSQL folks happy anyway.

Note: See TracTickets for help on using tickets.