[Xastir] Crash when reading shapefile
Tom Russo
russo at bogodyn.org
Sat Jun 20 16:11:58 EDT 2009
On Fri, Jun 19, 2009 at 11:42:59PM -0600, we recorded a bogon-computron collision of the <russo at bogodyn.org> flavor, containing:
> On Fri, Jun 19, 2009 at 11:47:50PM -0500, we recorded a bogon-computron collision of the <godfreja at gmail.com> flavor, containing:
> > On Fri, Jun 19, 2009 at 10:20 PM, Tom Russo<russo at bogodyn.org> wrote:
> > >
> > > Not a known error. ?The code is clearly *not* doing some error checking it
> > > should do (check for null pointer return from SHPReadObject before
> > > dereferencing it), but neither should SHPReadObject ever fail so long as you're
> > > accessing a shape number that's lower than the number in the file ?--- ?again,
> > > I suspect that the file is advertising more shapes than it actually contains.
> >
> > Well, you were right about the last shape returning null:
> > Reading entity 0... returned 0237cf20
> > Reading entity 1... returned 0237cf20
> > Reading entity 2... returned 0237cf20
> > Reading entity 3... returned 0237cf20
> > Reading entity 4... returned 0237cf20
> > ERROR 3: Error in fseek() or fread() reading object from .shp file.
> > Reading entity 5... returned 00000000
> > Bus error
> >
> >
> > However, when I run shpdump on the shapefile, I get entries for entiy 5:
> > Shape:5 (Arc) nVertices=36, nParts=1
> > Bounds:( -92.944, 46.011, 0, 0)
> > to ( -92.879, 46.125, 0, 0)
> > ( -92.879, 46.125, 0, 0) Ring
> > ( -92.892, 46.125, 0, 0)
> > <and so on>
>
> K. So it's not that there's no shape 5. But are there really 36 vertices in
> shape 5? There's clearly *something* wrong here that is making the shape
> read fail.
I just committed a change to shp_hash.c that protects against this segfault/bus
error by skipping any shapes for which SHPReadObject fails. There is similar
code in the map_shp.c file.
I don't know what's up with your shapefile, but if you really have no luck
diagnosing the problem, do a CVS update and see if you can move past this
problem by skipping the defective record. You'll still have the fread error
message, but it shouldn't cause a segfault anymore.
--
Tom Russo KM5VY SAR502 DM64ux http://www.swcp.com/~russo/
Tijeras, NM QRPL#1592 K2#398 SOC#236 http://kevan.org/brain.cgi?DDTNM
In some cultures what I do would be considered normal.
-- Ineffective daily affirmation
More information about the Xastir
mailing list