Opened 17 years ago

Closed 14 years ago

Last modified 14 years ago

#2109 closed defect (invalid)

Mapserver/Mapscript Crashes when rendering an empty OGR layer.

Reported by: plasmab Owned by: warmerdam
Priority: normal Milestone:
Component: OGR Support Version: 5.0
Severity: major Keywords: ogr
Cc: dmorissette

Description

SVN Checkout of mapserver/mapscript(php) crashes when rendering an empty OGR layer.

Attachments (1)

test_empty_layer.tar.gz (1.0 KB ) - added by Pinpin 16 years ago.
Example with empty MapInfo file

Download all attachments as: .zip

Change History (12)

comment:1 by plasmab, 17 years ago

This bug is caused by this change.

mapogr.cpp line 1270... a check should be made somewhere here to see if a layer has any features if not MS_DONE should be returned.

Stephen

comment:2 by plasmab, 17 years ago

Note that the way the code works a the moment the feature count check is after the first getnextfeature

comment:3 by plasmab, 17 years ago

Additional: GDAL/OGR/Mapserver versions that worked with the empty layer. (Requested by FrankW)

Previous mapserver version 4.4.2 Previous ogr/gdal version 1.2.6

comment:4 by plasmab, 17 years ago

The code checks the feature count. But it does the zero check after it tries to pull the first feature. (mapogr.cpp)

comment:5 by warmerdam, 17 years ago

Keywords: ogr added
Owner: changed from mapserverbugs to warmerdam

I take this one...

comment:6 by warmerdam, 17 years ago

Cc: dmorissette added
Status: newassigned

Stephen,

I tried to reproduce a problem with mapserver-svn (and mapserver 4.10 branch) shp2img on a simple mapfile with an ogr layer that has no features. The shp2img seemed to run without any problem.

I also reviewed the code and I don't see any obvious problem. Could you prepare a sample - preferrably a shp2img command + mapfile + data or even a PHP script+map+data to demonstrate the problem?

I reviewed the recent mapogr.cpp history and I don't see any change likely to have fixed this.

I'm adding DanielM as a cc: since I think he is working on a C conversion of mapogr.cpp and will need to be aware of changes.

comment:7 by warmerdam, 16 years ago

Milestone: 4.10.3 release5.0.1 release
Priority: highestnormal

Stephen,

I'm still waiting for details to reproduce this. I'm moving it on to 5.0.1 as a target.

comment:8 by warmerdam, 16 years ago

Resolution: worksforme
Status: assignedclosed

Plasmab,

I'm closing this since I can't reproduce it, and you haven't provided additional supporting info.

Please reopen if you can help me reproduce it.

by Pinpin, 16 years ago

Attachment: test_empty_layer.tar.gz added

Example with empty MapInfo file

comment:9 by Pinpin, 16 years ago

Component: MapScript-PHPOGR Support
Resolution: worksforme
Status: closedreopened
Version: 4.105.0

Hi, I reopen the bug because I have always the same problem with empty MapInfo files.

shp2img returns the following error :

msDrawMap(): Image handling error. Failed to draw layer named 'empty_layer'.
msOGRFileNextShape(): OGR error. InitBlockFromData(): Invalid Block Type: got 0 expected 2

I work with Mapserver 5.0.2 and gdla/ogr 1.4.2. I also attached an example with an empty MapInfo file and a mapfile.

comment:10 by warmerdam, 14 years ago

Milestone: 5.0.1 release
Resolution: invalid
Status: reopenedclosed

I have confirmed this problem and it appears to be an MITAB issue with empty TAB files, and having a spatial query active. MITAB issues a CPLError and then continues normally. MapServer is always has a spatial query in place, and mapogr.cpp is sensitive to issued CPLErrors since it tests GetLastError if NULL is returned by GetNextFeature().

I think MITAB needs is likely issuing an error when it is not necessary for empty TAB files.

I have filed this in the MITAB bugzilla as:

http://bugzilla.maptools.org/show_bug.cgi?id=2136

I do not believe any action is required in MapServer so I am closing this ticket. Sorry for the delay in followup analysis. I only ended up back here because I was wondering what to do with the test map I had originally prepared to test this issue. :-)

comment:11 by aboudreault, 14 years ago

For the record, this bug has been fixed in mitab, see http://bugzilla.maptools.org/show_bug.cgi?id=2136

Note: See TracTickets for help on using tickets.