Opened 15 years ago

Closed 15 years ago

#167 closed defect (fixed)

shp2pgsql double frees on medford buildings.shp

Reported by: pramsey Owned by: mcayland
Priority: high Milestone: PostGIS 1.4.0
Component: postgis Version: 1.4
Keywords: Cc:

Description

Run on the medford buildings.shp file and see the double free. Also seems to run much slower than 1.3 version.

Attachments (1)

buildings_oops.zip (785 bytes ) - added by pramsey 15 years ago.
3-point polygons in shape file

Download all attachments as: .zip

Change History (16)

comment:1 by pramsey, 15 years ago

shp2pgsql(73666) malloc: *** error for object 0x1bd1a30: double free
*** set a breakpoint in malloc_error_break to debug
INSERT 0 1
shp2pgsql(73666) malloc: *** error for object 0x1bd3c80: double free
*** set a breakpoint in malloc_error_break to debug
ERROR: geometry requires more points

Again, the validity checking is getting in the way of loading data.

comment:2 by warmerdam, 15 years ago

test

comment:3 by warmerdam, 15 years ago

test2

comment:4 by mcayland, 15 years ago

Again this is the same as #168, although it still brings up the question of what to do about validation.

Paul, I'm leaving this open in case you wish to comment about any of the speed issues.

ATB,

Mark.

comment:5 by mcayland, 15 years ago

Paul,

Do you have any further comments on the relative speeds or shall we just close the ticket?

ATB,

Mark.

comment:6 by pramsey, 15 years ago

It actually still double-frees, at r4153. I will see if I can make a terse example. The difficulty of working around these issues (I am going to load the file into 1.3, find the bad row, export that, then attach it) speaks to my worries about doing validity checking on load, even relatively trivial validity checking (closed rings, etc). Because fixing bad things requires a tool, and PostGIS is the tool that, presumably, a PostGIS user would like to use.

by pramsey, 15 years ago

Attachment: buildings_oops.zip added

3-point polygons in shape file

comment:7 by mcayland, 15 years ago

Hmmm works fine for me:

pg83@zeno:~/src/postgis-svn/testdata$ shp2pgsql buildings_oops test > foo Shapefile type: PolygonZ Postgis type: MULTIPOLYGON[4] ERROR: geometry requires more points

Did you definitely rebuild liblwgeom since the fix went in?

ATB,

Mark.

comment:8 by robe, 15 years ago

I get an error too Mark and just svn uped/autogen/configure/compile/install

I'm testing on 8.2 on OpenSUSE 10.3 If I do this: postgis-1.4SVN/loader/shp2pgsql buildings_oops public.buildings | psql -h localhost -d testpostgis -U postgres

I get this error

addgeometrycolumn


public.buildings.the_geom SRID:-1 TYPE:MULTIPOLYGON DIMS:4

(1 row)

ERROR: syntax error at end of input LINE 1: …S-BUILDING','1384.22300000','0.00000000000','0.00000000000',

If I do this postgis-1.4SVN/loader/shp2pgsql buildings_oops public.buildings > buildings.sql

I get Shapefile type: PolygonZ Postgis type: MULTIPOLYGON[4] * glibc detected * postgis-1.4SVN/loader/shp2pgsql: double free or corruption (fasttop): 0x08079f40 * ======= Backtrace: ========= /lib/libc.so.6[0xb7eb94b6] /lib/libc.so.6(cfree+0x89)[0xb7ebb179] postgis-1.4SVN/loader/shp2pgsql(default_freeor+0x1d)[0x805e2fd] postgis-1.4SVN/loader/shp2pgsql(lwfree+0x20)[0x805e100] postgis-1.4SVN/loader/shp2pgsql[0x805e9f0] postgis-1.4SVN/loader/shp2pgsql(output_wkb_polygon_collection+0x27)[0x805ea97] postgis-1.4SVN/loader/shp2pgsql[0x805eb7c] postgis-1.4SVN/loader/shp2pgsql(output_wkb+0x145)[0x805ecd5] postgis-1.4SVN/loader/shp2pgsql[0x805eb7c] postgis-1.4SVN/loader/shp2pgsql(output_wkb+0x145)[0x805ecd5] postgis-1.4SVN/loader/shp2pgsql[0x805ef41] postgis-1.4SVN/loader/shp2pgsql[0x805771f] postgis-1.4SVN/loader/shp2pgsql[0x80529e5] postgis-1.4SVN/loader/shp2pgsql[0x8053135] postgis-1.4SVN/loader/shp2pgsql[0x8053239] /lib/libc.so.6(libc_start_main+0xe0)[0xb7e68fe0] postgis-1.4SVN/loader/shp2pgsql[0x804a371] ======= Memory map: ======== 08048000-08077000 r-xp 00000000 08:01 1591187 /projects/postgis-1.4SVN/loader/shp2pgsql 08077000-08078000 r—p 0002f000 08:01 1591187 /projects/postgis-1.4SVN/loader/shp2pgsql 08078000-08079000 rw-p 00030000 08:01 1591187 /projects/postgis-1.4SVN/loader/shp2pgsql 08079000-0809a000 rw-p 08079000 00:00 0 [heap] b7d00000-b7d21000 rw-p b7d00000 00:00 0 b7d21000-b7e00000 —-p b7d21000 00:00 0 b7e2d000-b7e2e000 rw-p b7e2d000 00:00 0 b7e2e000-b7e51000 r-xp 00000000 08:01 1556613 /lib/libm-2.6.1.so b7e51000-b7e53000 rw-p 00022000 08:01 1556613 /lib/libm-2.6.1.so b7e53000-b7f80000 r-xp 00000000 08:01 1557842 /lib/libc-2.6.1.so b7f80000-b7f81000 r—p 0012c000 08:01 1557842 /lib/libc-2.6.1.so b7f81000-b7f83000 rw-p 0012d000 08:01 1557842 /lib/libc-2.6.1.so b7f83000-b7f87000 rw-p b7f83000 00:00 0 b7f87000-b7f91000 r-xp 00000000 08:01 1556721 /lib/libgcc_s.so.1 b7f91000-b7f93000 rw-p 00009000 08:01 1556721 /lib/libgcc_s.so.1 b7f93000-b7f97000 rw-p b7f93000 00:00 0 b7f97000-b7fb1000 r-xp 00000000 08:01 1556546 /lib/ld-2.6.1.so b7fb1000-b7fb3000 rw-p 0001a000 08:01 1556546 /lib/ld-2.6.1.so bf86e000-bf884000 rw-p bf86e000 00:00 0 [stack] ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso] Aborted

comment:9 by robe, 15 years ago

This is interesting — If I do this postgis-1.4SVN/loader/shp2pgsql -S buildings_oops public.buildings > buildings.sql I get: Shapefile type: PolygonZ Postgis type: POLYGON[4] ERROR: geometry requires more points

comment:10 by mcayland, 15 years ago

Hmmm. Still can't reproduce here. I did notice that you didn't do a "make clean" before configure to ensure that liblwgeom gets updated and built into postgis-1.4.so - can you try this just to be 100% certain?

ATB,

Mark.

comment:11 by robe, 15 years ago

Just did a make clean, remake, install and still aborts with the same error.

I guess I can try and wipe out my whole directory and redownload to be sure. I'll do that next.

comment:12 by pramsey, 15 years ago

No, the make clean monster hasn't bitten me again (another issue that deserves a ticket, really) after a clean build the problem still recurs. I'm on OS/X 10.5 should be 32 bit.

Heron-2:postgis-svn pramsey$ ./loader/shp2pgsql ~/Downloads/buildings_oops/buildings_oops.shp foo
Shapefile type: PolygonZ
Postgis type: MULTIPOLYGON[4]
SET STANDARD_CONFORMING_STRINGS TO ON;
BEGIN;
CREATE TABLE "foo" (gid serial PRIMARY KEY,
"layer" varchar(254),
"elevation" numeric,
"shape_leng" numeric,
"shape_area" numeric);
SELECT AddGeometryColumn('','foo','the_geom','-1','MULTIPOLYGON',4);
shp2pgsql(27700) malloc: *** error for object 0x1009c0: double free
*** set a breakpoint in malloc_error_break to debug
shp2pgsql(27700) malloc: *** error for object 0x100ae0: double free
*** set a breakpoint in malloc_error_break to debug
ERROR: geometry requires more points
INSERT INTO "foo" ("layer","elevation","shape_leng","shape_area",the_geom) VALUES ('S-BUILDING','1384.22300000','0.00000000000','0.00000000000',
Heron-2:postgis-svn pramsey$ 

comment:13 by robe, 15 years ago

Owner: changed from pramsey to mcayland

comment:14 by mcayland, 15 years ago

Gah. Looks like I forgot to apply the fix for #156 to the WKB part of the unparser too :( Can you "svn up" to r4165 and try again - this seems to fix the issue on my i386 virtual anyhow.

ATB,

Mark.

comment:15 by robe, 15 years ago

Resolution: fixed
Status: newclosed

Works

Note: See TracTickets for help on using tickets.