<br><font size=2 face="Courier">Hallo Umberto and Christian</font>
<br>
<br><font size=2 face="Courier">Christian reported a crash in layerObj.delete()
which I</font>
<br><font size=2 face="Courier">also detected. </font>
<br><font size=2 face="Courier">I think I understood the following:</font>
<br>
<br><font size=2 face="Courier">Let's say, we have an initialized mapObj
mO;</font>
<br>
<br><font size=2 face="Courier">layerObj lO = new layerObj(mO);</font>
<br><font size=2 face="Courier">// Say lO is the 5th layer now.</font>
<br><font size=2 face="Courier">// Now lO.swigCMemOwn == true and</font>
<br><font size=2 face="Courier">// lO.swigCPtr points onto
the mO.swigCPtr->layers[4]</font>
<br>
<br><font size=2 face="Courier">...</font>
<br><font size=2 face="Courier">// now the mapObj is deleted but the Java-layerObj
continues to live.</font>
<br><font size=2 face="Courier">// the C-layer-Object mO.swigCPtr->layers[4]
will deleted and freed also!</font>
<br><font size=2 face="Courier">mO.delete()</font>
<br><font size=2 face="Courier">// From now on O.swigCPtr points into invalid
piece of C-memory.</font>
<br><font size=2 face="Courier">...</font>
<br>
<br><font size=2 face="Courier">Later on the Java-garbage-collector finalizes
the layerObj. </font>
<br>
<br><font size=2 face="Courier">Because of "lO.swigCMemOwn == true"
and "lO.swigCPtr!=0" the finalize-method calls </font>
<br><font size=2 face="Courier">layerObj.delete(). This method frees lO.swigCPtr
which is invalid memory.</font>
<br>
<br><font size=2 face="Courier">Same story about layerObj/classObj. </font>
<br>
<br><font size=2 face="Courier">Benedikt Rothe</font>
<br>
<br>
<br>
<br><font size=2 face="Courier">UMN MapServer Users List <MAPSERVER-USERS@LISTS.UMN.EDU>
schrieb am 28.06.2005 12:16:01:<br>
<br>
> Hello Umberto,<br>
> <br>
> Umberto Nicoletti wrote:<br>
> <br>
> >Hi Christian,<br>
> >I do not think the error you are getting is due to threading issues,<br>
> >but trying what Mario suggests will at least narrow the search
field.<br>
> ><br>
> >In case you are still getting errors even with synchronized code<br>
> >blocks I have a few questions for you to help me understand your<br>
> >setup:<br>
> >Do you always get errors in delete_classObj or do the segfaults
happen<br>
> >in different functions?<br>
> ><br>
> ><br>
> Yes, the segfaults alway happen in the delete_classObj function.<br>
> <br>
> >If the segfault is always caused by<br>
> >delete_ClassObj then I suppose you are creating class objects
in your<br>
> >java code. Is that true?<br>
> ><br>
> ><br>
> Yes, that's true, I need to create classObjects.<br>
> <br>
> >If that is the case then we can setup a very simple test to reproduce<br>
> >the problem: modify one of the examples so that it will load a
map and<br>
> >then start adding classes in similar fashion to your code, but
in a<br>
> >tight loop. Classes should be made eligible for gc by dropping
all<br>
> >references to them. As soon as gc kicks in the vm should crash.
At<br>
> >that point it will be clear that the problem is in delete_ClassObj
and<br>
> >the hunting season will be open.<br>
> ><br>
> ><br>
> I have tested a proposed solution by Benedikt Rothe yet, which said
that<br>
> one should call the delete method of the classObject after it is not<br>
> needed any more.<br>
> This confirms my assumption that this problem occours when java's<br>
> garbage-collector destroys the null-referenced objects. Now it seems
to<br>
> work properly.<br>
> <br>
> The mapserver version we actually use is 4.4.1, we have tested 4.4.2,<br>
> 4.2.4 and 4.6.0, too before.<br>
> <br>
> Thank you all for your help!<br>
> <br>
> Best Regards,<br>
> Christian :-)<br>
> <br>
> <br>
> >BTW can you report the mapserver version you are using (I have
4.4.2<br>
> >and I know it works, so if you can use that).<br>
> ><br>
> >Best Regards,<br>
> >Umberto<br>
> ><br>
> >On 6/21/05, Christian Schroeder <mailings@abiwood99.de>
wrote:<br>
> ><br>
> ><br>
> >>Hello Umberto,<br>
> >><br>
> >>thank your for your immediate answer.<br>
> >>I do not call the delete_ methody directly and don't think
I am using<br>
> >>special gc parameters.<br>
> >><br>
> >>And... I have read the README file before compiling the mapserver
:-)<br>
> >><br>
> >>I will try to get it to work with "synchronized"-flags
als Mario Basa<br>
> >>supposed.<br>
> >><br>
> >>Thank you!<br>
> >><br>
> >>Christian<br>
> >><br>
> >><br>
> >>Umberto Nicoletti schrieb:<br>
> >><br>
> >><br>
> >><br>
> >>>Christian,<br>
> >>>are you calling the delete_ methods directly in your code
or are you<br>
> >>>using some special gc paramaters?<br>
> >>><br>
> >>>As a side note the --use-threads option to configure is
*absolutely*<br>
> >>>necessary, as are brakes on your car. I think we should
write it in<br>
> >>>the README (as if someone actually cared to read it :-(
).<br>
> >>><br>
> >>>Best regards,<br>
> >>>Umberto<br>
> >>><br>
> >>><br>
> >>>On 6/21/05, Sean Gillies <sgillies@frii.com> wrote:<br>
> >>><br>
> >>><br>
> >>><br>
> >>><br>
> >>>>I'm forwarding this to the users list. Hopefully,
Umberto will be able<br>
> >>>>to provide some insight.<br>
> >>>><br>
> >>>>cheers,<br>
> >>>>Sean<br>
> >>>><br>
> >>>>On Jun 16, 2005, at 5:08 PM, Christian Schröder wrote:<br>
> >>>><br>
> >>>><br>
> >>>><br>
> >>>><br>
> >>>><br>
> >>>>>Dear Mr. Gillies,<br>
> >>>>><br>
> >>>>>some weeks ago me and Florian Pepping contacted
you because we had<br>
> >>>>>problems using the Java Mapscript API. Thanks
to you we could solve<br>
> >>>>>these problems :-)<br>
> >>>>><br>
> >>>>>Now we got our program doing what it's supposed
to do but there is<br>
> >>>>>still a big problem left which we were not able
to solve yet:<br>
> >>>>>We created a simple servlet which is created inside
a Tomcat 5.0<br>
> >>>>>Webserver. This servlet created a map image (png/jpg)
and displays<br>
> >>>>>some specified objects on the map. (We use it
for location based<br>
> >>>>>services --> "show me the position of
the next printer").<br>
> >>>>>After an irregular number of calls of our servlet
which uses the Java<br>
> >>>>>Mapscript API the complete Java VM and with it
the Tomcat crashes. I<br>
> >>>>>attached the error report below. The program works
properly for a<br>
> >>>>>number of calls (between 5 and 1000 :-) ) and
after that it crashes.<br>
> >>>>>We have tried several versions of the mapserver
(4.4.1, 4.4.2, 4.2.4,<br>
> >>>>>4.6.1 RC1) and compiled the Java Mapscript Module
with JDK 1.4.2 and<br>
> >>>>>1.5.0. We also configured mapserver using the
--with-threads option,<br>
> >>>>>but all this did not help. By the way the mapserv
cgi-module works<br>
> >>>>>properly.<br>
> >>>>><br>
> >>>>>Do you have an idea for this?<br>
> >>>>><br>
> >>>>>Thanks for your anxiety<br>
> >>>>><br>
> >>>>>Christian & Florian<br>
> >>>>>University of Paderborn, Germany<br>
> >>>>><br>
> >>>>><br>
> >>>>>-------------------------------------------------------------------<br>
> >>>>><br>
> >>>>>JavaMapscriptLoader: mapscript native library
has been loaded.<br>
> >>>>>* mapscript native library loaded *<br>
> >>>>><br>
> >>>>>An unexpected exception has been detected in native
code outside the<br>
> >>>>>VM.<br>
> >>>>>Unexpected Signal : 11 occurred at PC=0x3338268<br>
> >>>>>Function=delete_classObj+0x8<br>
> >>>>>Library=/usr/lib/libmapscript.so<br>
> >>>>><br>
> >>>>>Current Java thread:<br>
> >>>>> at edu.umn.gis.mapscript.mapscriptJNI.delete_classObj(Native<br>
> >>>>>Method)<br>
> >>>>> at edu.umn.gis.mapscript.classObj.delete(classObj.java:32)<br>
> >>>>> at edu.umn.gis.mapscript.classObj.finalize(classObj.java:26)<br>
> >>>>> at java.lang.ref.Finalizer.invokeFinalizeMethod(Native
Method)<br>
> >>>>> at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)<br>
> >>>>> at java.lang.ref.Finalizer.access$100(Finalizer.java:14)<br>
> >>>>> at<br>
> >>>>>java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:160)<br>
> >>>>><br>
> >>>>>Dynamic libraries:<br>
> >>>>>Can not get information for pid = 10558<br>
> >>>>><br>
> >>>>>Heap at VM Abort:<br>
> >>>>>Heap<br>
> >>>>>def new generation total 1152K, used 135K
[0x08ae0000, 0x08c20000,<br>
> >>>>>0x08fc0000)<br>
> >>>>> eden space 1024K, 0% used [0x08ae0000,
0x08ae4078, 0x08be0000)<br>
> >>>>> from space 128K, 100% used [0x08c00000, 0x08c20000,
0x08c20000)<br>
> >>>>> to space 128K, 0% used [0x08be0000,
0x08be0000, 0x08c00000)<br>
> >>>>>tenured generation total 15048K, used 13624K
[0x08fc0000,<br>
> >>>>>0x09e72000,<br>
> >>>>>0x0cae0000)<br>
> >>>>> the space 15048K, 90% used [0x08fc0000,
0x09d0e1c0, 0x09d0e200,<br>
> >>>>>0x09e72000)<br>
> >>>>>compacting perm gen total 18432K, used 18373K
[0x0cae0000,<br>
> >>>>>0x0dce0000,<br>
> >>>>>0x10ae0000)<br>
> >>>>> the space 18432K, 99% used [0x0cae0000,
0x0dcd1618, 0x0dcd1800,<br>
> >>>>>0x0dce0000)<br>
> >>>>><br>
> >>>>>Local Time = Tue Jun 14 15:32:19 2005<br>
> >>>>>Elapsed Time = 246<br>
> >>>>>#<br>
> >>>>># The exception above was detected in native code
outside the VM<br>
> >>>>>#<br>
> >>>>># Java VM: Java HotSpot(TM) Client VM (1.4.2_08-b03
mixed mode)<br>
> >>>>>#<br>
> >>>>># An error report file has been saved as /tmp/hs_err_pid10558.log.<br>
> >>>>># Please refer to the file for further information.<br>
> >>>>>#<br>
> >>>>><br>
> >>>>>-------------------------------------------------------------------<br>
> >>>>><br>
> >>>>>On Mar 22, 2005, at 12:02 PM, Florian Pepping
wrote:<br>
> >>>>><br>
> >>>>><br>
> >>>>><br>
> >>>>><br>
> >>>>><br>
> >>>>>>Dear Mr. Gillies,<br>
> >>>>>><br>
> >>>>>>I'm a student of the University of Paderborn
in Germany and member of<br>
> >>>>>>the project group "Location Based Services
for Wireless Devices". In<br>
> >>>>>>this project we try to position laptops and
other WLAN-enabled<br>
> >>>>>>devices using the signal strength of
the WLAN. According to their<br>
> >>>>>>position, we want to offer location
based services to the persons<br>
> >>>>>>using the devices (where I am; where's
the next printer; is there a<br>
> >>>>>>friend nearby)<br>
> >>>>>><br>
> >>>>>>In order to do this, we want to use your mapserver
and the Java<br>
> >>>>>>Mapscript API to generate maps according to
the actual position and<br>
> >>>>>>situation. We like to customize the map of
our building and add<br>
> >>>>>>points, lines and so on.<br>
> >>>>>><br>
> >>>>>>We have been able to compile the whole mapserver
and the Java<br>
> >>>>>>Mapscript API. A small Java example also works,
which presents an<br>
> >>>>>>unchanged map of our building.<br>
> >>>>>><br>
> >>>>>>[...]<br>
> >>>>>><br>
> >>>>>><br>
> >>>>>><br>
> >>>>>><br>
> >>><br>
> >>><br>
> >>><br>
> >>><br>
> ><br>
> ><br>
> ><br>
> ><br>
</font>