Hi all,

My tests of the Python module include a test of query result set members and getFeature. See mapscript/python/tests/cases/ resultcachetest.py. I have not been routinely building or testing mapscript with the --with-geos option, but I reconfigured today and the tests pass as usual. This seems to point to this being a Java specific problem.

Now that I look at your Java code, I see a potential problem. You shouldn't make the assumption that the tileindex of your resultCacheMemberObj is always -1. I'm not sure that figures into the current issue, but is something you'll want to beware of in the future.

Sean

On Nov 17, 2005, at 9:25 PM, Steve Lime wrote:

Hmmm.... The geometry member is initialized to NULL and not used unless = you do something like a buffer or a convex hull. The code to free the = geometry does check to make sure the geometry is not NULL before unallocati=
ng it. This leads me to believe the problem is not GEOS per se but =
elsewhere in the query or MapScript code- perhaps someplace that doesn't = use msInitShape() to initialize a shapeObj structure, which could lead to =
an unitialized geometry pointer. I guess we should try the same code =
snippet in another MapScript flavor to make sure it's not a java specific =
issue.

Steve

Donovan <[EMAIL PROTECTED]> 11/16/05 12:07 PM >>>
You've got my attention. Donovan do you have any more specific information=

regarding the GEOS crash?   --Steve

Sure,

I'm using mapserver 4.8.0beta - but 4.6.0 breaks too
--geos-2.1.1 from rpm (gdal-1.2.6 and proj-4.4.9 also)
--FedoraCore3 with java1.5 (glibc-2.3.5)

I think the crash occurs any time a shapeObj is returned.

I modified the java mapscript example class DrawMap from the mapserver
source tree to demonstrate the problem - Query.java is attached.

Without GEOS, Query.java generates the png but with GEOS, it looks like =
this:
# cd ~/mapserver-4.8.0-beta1/mapscript/java
# javac -classpath ./:examples/:./mapscript.jar -d examples/ examples/*.jav=
a
# java -classpath ./:examples/:./mapscript.jar - Djava.library.path=3D. =
Query
../../tests/test.map ./map.png

The map will be drawn to:./map.png
*** glibc detected *** malloc(): memory corruption: 0xb1c11ee8 ***
Aborted

From poking around in the source i think the crash happens while freeing =
the
geometry pointer in the shape obj but i didn't get any further.

If there is anything else i can provide or if some testing is required i'd
be happy to help...

Thanks for your attention


----mapscript/java/examples/Query.java----cut-here--
import edu.umn.gis.mapscript.*;

public class Query {

  public static void usage() {
    System.err.println("Usage: Query {mapfile} {outfile}");
    System.exit(-1);
  }

  public static void main(String[] args) {
    if (args.length !=3D 2) usage();
        try
        {
          System.loadLibrary("mapscript");
        }
        catch(UnsatisfiedLinkError ule)
        {
          System.err.println(ule);
          System.exit(-1);
        }

    mapObj map =3D new mapObj(args[0]);
    map.getImagecolor().setRGB(153, 153, 204);
    styleObj st =3D map.getLayer(1).getClass(0).getStyle(0);
    st.getColor().setHex("#000000");
    imageObj img =3D map.draw();
    System.out.println("The map will be drawn to:"+args[1]);

    layerObj layer =3D map.getLayerByName("POLYGON");
    layer.setTemplate("dummy.template");
    layer.queryByPoint(map,new pointObj(0.10,51.4,0),
        mapscriptConstants.MS_MULTIPLE,-1);
    resultCacheObj results =3D layer.getResults();
    layer.open();
    for (int i=3D0;i<results.getNumresults();i++) {
       resultCacheMemberObj result =3D results.getResult(i);
       //CRASH HAPPENS ON NEXT LINE
shapeObj feature =3D layer.getFeature(result.getShapeindex (),-1);
    }
    layer.close();

    img.save(args[1], map);
  }
}
-----End of Query.java----------

---
Sean Gillies
sgillies at frii dot com
http://zcologia.com/news

Reply via email to