[R-sig-Geo] gUnion causes segfault

Roger Bivand Roger.Bivand at nhh.no
Thu Jun 9 19:17:16 CEST 2011


On Thu, 2 Jun 2011, Roger Bivand wrote:

> On Thu, 2 Jun 2011, Barry Rowlingson wrote:
>
>> I get a buffer overflow and a nice traceback that might be helpful:
>> 
>> *** buffer overflow detected ***: /usr/lib/R/bin/exec/R terminated
>> ======= Backtrace: =========
>> /lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x50)[0x1f3390]
>> /lib/tls/i686/cmov/libc.so.6(+0xe12ca)[0x1f22ca]
>> /lib/tls/i686/cmov/libc.so.6(__strcpy_chk+0x44)[0x1f1644]
>> /home/rowlings/R/i486-pc-linux-gnu-library/2.12/rgeos/libs/rgeos.so(RGEOS_comment2comm+0x8f)[0xc70aff]
>
> Thanks - this is in the code for trying to construct OGC SFS alike Polygon or 
> MultiPolygon objects from R/sp Polygons objects. I'll try to see what it is.

rgeos 0.1-7 has been submitted to CRAN and will be available shortly. When 
the dissolve set included very many polygons, the comment string, used to 
record which polygons are inside which others, seems to have got too long, 
because UnionCascaded in GEOS 3.2.2 did not accept GeometryCollection 
objects.

In GEOS 3.3.0, UnaryUnion does accept GeometryCollection objects, so 
unflattened sp objects may be used, avoiding the need to construct a 
Polygons object with thousands of member Polygon objects.

With GEOS 3.2.2, one needs to dissolve in two stages, first in subsets for 
dissolve sets with over 1000 objects, then once they have been dissolved, 
the second dissolve step on the intermediate sets. Tiling the input data 
with Sobj_SpatialGrid() in maptools is a possible solution.

Thanks to Brian for reproducible examples and to Barry for accurate 
diagnostics,

Roger

>
> Roger
>
>> /home/rowlings/R/i486-pc-linux-gnu-library/2.12/rgeos/libs/rgeos.so(rgeos_Polygons2geospolygon+0x5c)[0xc73a8c]
>> /home/rowlings/R/i486-pc-linux-gnu-library/2.12/rgeos/libs/rgeos.so(rgeos_SpatialPolygons2geospolygon+0x8b)[0xc73d7b]
>> /home/rowlings/R/i486-pc-linux-gnu-library/2.12/rgeos/libs/rgeos.so(rgeos_convert_R2geos+0x548)[0xc74a58]
>> /home/rowlings/R/i486-pc-linux-gnu-library/2.12/rgeos/libs/rgeos.so(rgeos_topologyfunc+0x51)[0xc7cf61]
>> /home/rowlings/R/i486-pc-linux-gnu-library/2.12/rgeos/libs/rgeos.so(rgeos_unioncascaded+0x3c)[0xc7d1cc]
>> [etc]
>> 
>> My rgeos is:
>> 
>> rgeos: (SVN revision (unknown))
>> GEOS runtime version: 3.2.2-CAPI-1.6.2
>> Polygon checking: TRUE
>> 
>> Version: 0.1-6
>> 
>> Barry
>> 
>
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list