MapServer / MapServer-import

3 stars 2 forks source link

Mapserver/Mapscript Crashes when rendering an empty OGR layer. #2109

Open tbonfort opened 12 years ago

tbonfort commented 12 years ago

Reporter: plasmab Date: 2007/06/04 - 12:45 SVN Checkout of mapserver/mapscript(php) crashes when rendering an empty OGR layer.

tbonfort commented 12 years ago

Author: plasmab Date: 2007/06/04 - 15:11 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

tbonfort commented 12 years ago

Author: plasmab Date: 2007/06/04 - 15:22 Note that the way the code works a the moment the feature count check is after the first getnextfeature

tbonfort commented 12 years ago

Author: plasmab Date: 2007/06/04 - 17:28 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

tbonfort commented 12 years ago

Author: plasmab Date: 2007/06/04 - 17:31 The code checks the feature count. But it does the zero check after it tries to pull the first feature. (mapogr.cpp)

tbonfort commented 12 years ago

Author: warmerdam Date: 2007/07/30 - 19:35 I take this one...

tbonfort commented 12 years ago

Author: warmerdam Date: 2007/07/30 - 19:50 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.

tbonfort commented 12 years ago

Author: warmerdam Date: 2007/11/01 - 18:19 Stephen,

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

tbonfort commented 12 years ago

Author: warmerdam Date: 2007/12/01 - 04:27 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.

tbonfort commented 12 years ago

Author: Pinpin Date: 2008/05/28 - 11:06 Hi, I reopen the bug because I have always the same problem with empty MapInfo files.[[BR]][[BR]] shp2img returns the following error :[[BR]]

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.

tbonfort commented 12 years ago

Author: warmerdam Date: 2009/12/26 - 17:30 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. :-)

tbonfort commented 12 years ago

Author: aboudreault Date: 2010/01/08 - 23:10 For the record, this bug has been fixed in mitab, see http://bugzilla.maptools.org/show_bug.cgi?id=2136