GDAL failure in call from java mapscript

Ben Tuttle funkbucket at GMAIL.COM
Thu Aug 30 16:53:27 EDT 2007


Hi all-
We are doing some work with java mapscript and are running into some
problems. This has worked fine for the most part.  However, in one of
our test cases we've come across what appears to be a bug, that in our
case takes down the entire webserver.  Any info on what might be
causing our problem would be greatly appreciated.

Here are the details:
Windows XP, Mapserver 4.10, gdal1.4.1, Java 1.6, Tomcat 6.0
MapServer version 4.10.2 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP
OUTPUT=PDF OUTPUT=SWF OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=FREETYPE
SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER
SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER
SUPPORTS=FASTCGI SUPPORTS=THREADS SUPPORTS=GEOS INPUT=JPEG
INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE DEBUG=MSDEBUG

The bug arose when calling making a WMS request to Mapserver through
tomcat.  The following URLs succeed:

https://wahlstrom-670/Dispatcher/wms.do?map=/boulder_data/bldr.map&REQUEST=GetMap&LAYERS=zoning_08_05,openspace09_05&TRANSPARENT=true&srs=EPSG:4326&bbox=-106,39.5,-105,40.5&format=image/png&VERSION=1.1.1&styles=&SERVICE=WMS

https://wahlstrom-670/Dispatcher/wms.do?map=/boulder_data/bldr.map&REQUEST=GetMap&LAYERS=zoning_08_05,openspace09_05&TRANSPARENT=true&srs=EPSG:4326&bbox=-106,39.5,-105,40.5&format=image/gif&VERSION=1.1.1&styles=&SERVICE=WMS


 This one however fails catastrophically, taking down the webserver and the JVM

https://wahlstrom-670/Dispatcher/wms.do?map=/boulder_data/bldr.map&REQUEST=GetMap&LAYERS=zoning_08_05,openspace09_05&TRANSPARENT=true&srs=EPSG:4326&bbox=-106,39.5,-105,40.5&format=image/tiff&VERSION=1.1.1&styles=&SERVICE=WMS


Note that the only difference is that the format QS parameter has been
changed from "image/png" to "image/tiff".



To further debug this problem we wrote a simple java app to call mapscript :



import java.io.*;

import edu.umn.gis.mapscript.*;



public class MapScriptTest {



  public static void main(String[] args)  {

      try {

            OWSRequest req = new OWSRequest();

            req.setParameter( "SERVICE", "WMS");

            req.setParameter( "REQUEST", "GetMap");

            req.setParameter( "LAYERS", "US state boundaries");

            req.setParameter( "format", "image/tiff");

            req.setParameter( "version", "1.1.1");



            mapObj map = new mapObj("USA.map");



            mapscript.msIO_installStdoutToBuffer();



            int owsResult = map.OWSDispatch( req );

            mapscript.msIO_stripStdoutBufferContentType();



            byte[] resultBytes = mapscript.msIO_getStdoutBufferBytes();



          FileOutputStream fou = new FileOutputStream(new File("map.tiff"));

          fou.write(resultBytes);

          fou.flush();

          fou.close();



      } catch( Exception e ) {

          e.printStackTrace();

      }

  }

}



Running this program on our system will generate a seg fault in
gdal14.dll.  Java reports the following:



#

# An unexpected error has been detected by Java Runtime Environment:

#

#  EXCEPTION_STACK_OVERFLOW (0xc00000fd) at pc=0x0328dcb5, pid=1180, tid=3208

#

# Java VM: Java HotSpot(TM) Client VM (1.6.0_02-b06 mixed mode, sharing)

# Problematic frame:

# C  [gdal14.dll+0x24dcb5]

#

# If you would like to submit a bug report, please visit:

#   http://java.sun.com/webapps/bugreport/crash.jsp

#

.

.

.



We can repro this on both prebuilt binaries and ones I build ourself.



There are some files for a small re-pro program at
http://www.waterstoneinc.com/7e70820538e2ea58949752422edbdaf6/:

·         MapScriptTest.java – Simple driver java program

·         HelloWorld.map – Simple example map

·         Mapscript.dll – The mapscript DLL I'm using. Feel free to use your own

·         buildAndRun.cmd – a cmd file to compile the java code and
run it with four sets of sample parameters. The last of which will
cause the seg fault.



Note: you will likely need to edit buildAndRun.cmd to make sure you
are adding all the referenced mapscript DLLs to your path.



More information about the mapserver-users mailing list