Mapscript ,Mono, Apache and Linux : a great story

Xavier Mauclaire xavier.mauclaire at GEOTER.FR
Mon Jun 19 12:05:37 EDT 2006


 
Objet : RE: [UMN_MAPSERVER-USERS] Mapscript ,Mono, Apache and Linux : a
great story

 
Tamas,

I did the following test before attempting to apply modifications you've
suggested.

I disabled the pMapSetSelection function in my program (It's the implest way
to test) . When i run the site, i get error about getfeature. Apparently
disabling this function doesn't avoid the getfeature segmentation fault. 



regards

Error_log

=================================================================
Got a SIGSEGV while executing native code. This usually indicates a fatal
error in the mono runtime or one of the native libraries used by your
application.
=================================================================

Stacktrace:

in (wrapper managed-to-native) mapscriptPINVOKE:layerObj_getFeature
(System.Runtime.InteropServices.HandleRef,int,int) <0x4> in (wrapper
managed-to-native) mapscriptPINVOKE:layerObj_getFeature
(System.Runtime.InteropServices.HandleRef,int,int) <0xffffff87> in
layerObj:getFeature (int,int) <0x27> in
siteflash.GetParcelleReglement:croisement_reglement (shapeObj) <0x12b> in
siteflash.GetParcelleReglement:ProcessRequest (System.Web.HttpContext)
<0x5b1> in <Pipeline>__1:MoveNext () <0x10a0> in
System.Web.HttpApplication:Tick () <0x1f> in
System.Web.HttpApplication:Start (object) <0x37> in
System.Web.HttpApplication:System.Web.IHttpAsyncHandler.BeginProcessRequest
(System.Web.HttpContext,System.AsyncCallback,object) <0x68> in
System.Web.HttpRuntime:RealProcessRequest (object) <0x1ab> in
System.Web.HttpRuntime:ProcessRequest (System.Web.HttpWorkerRequest) <0x2c>
in Mono.WebServer.MonoWorkerRequest:ProcessRequest () <0xa> in
Mono.WebServer.BaseApplicationHost:ProcessRequest
(Mono.WebServer.MonoWorkerRequest) <0x43> in
Mono.WebServer.ModMonoApplicationHost:ProcessRequest
(int,string,string,string,string,string,int,string,int,string,string[],strin
g[]) <0xdc> in (wrapper remoting-invoke-with-check)
Mono.WebServer.ModMonoApplicationHost:ProcessRequest
(int,string,string,string,string,string,int,string,int,string,string[],strin
g[]) <0xffffff0a> in (wrapper xdomain-dispatch)
Mono.WebServer.ModMonoApplicationHost:ProcessRequest
(object,byte[]&,byte[]&,int,string,string,string,string,string,int,string,in
t,string,string[],string[]) <0xfffee026> in (wrapper xdomain-invoke)
Mono.WebServer.ModMonoApplicationHost:ProcessRequest
(int,string,string,string,string,string,int,string,int,string,string[],strin
g[]) <0xffffff6a> in (wrapper remoting-invoke-with-check)
Mono.WebServer.ModMonoApplicationHost:ProcessRequest
(int,string,string,string,string,string,int,string,int,string,string[],strin
g[]) <0xffba766c> in Mono.WebServer.ModMonoWorker:InnerRun (object) <0x404>
in Mono.WebServer.ModMonoWorker:Run (object) <0x17> in (wrapper
delegate-invoke) System.MulticastDelegate:invoke_void_object (object)
<0xffffff95> in (wrapper runtime-invoke)
System.Object:runtime_invoke_void_object (object,intptr,intptr,intptr)
<0xc7371b5f>

Native stacktrace:

	/usr/lib/pkgconfig/../../bin/mono(mono_handle_native_sigsegv+0xbb)
[0x814ee2b]
	/usr/lib/pkgconfig/../../bin/mono [0x813b2cf]
	[0xffffe440]
	/lib/tls/libc.so.6(malloc+0x86) [0x40187ea6]
	/usr/local/lib/libmapscript.so(strstrIgnoreCase+0x47) [0x419316f7]
	/usr/local/lib/libmapscript.so [0x41931804]
	/usr/local/lib/libmapscript.so(msPOSTGISLayerGetShape+0x7d)
[0x41931e5d]
	/usr/local/lib/libmapscript.so(msPOSTGISLayerGetShapeVT+0x23)
[0x419325b3]
	/usr/local/lib/libmapscript.so(msLayerGetShape+0x2e) [0x418e7b3e]
	/usr/local/lib/libmapscript.so(CSharp_layerObj_getFeature+0x46)
[0x418a3636]
	[0x41861b62]
	[0x41861a80]
	[0x418622cc]
	[0x4186029a]
	[0x416f6421]
	[0x416f52a8]
	[0x416f1668]
	[0x416f1549]
	[0x4125149c]
	[0x41250fcd]
	[0x41250f8b]
	[0x41250544]
	[0x412355ad]
	[0x41234d14]
	[0x41234af3]
	[0x41222807]
	[0x41222643]
	[0x40dc9bdd]
	[0x40dc9730]
	[0x40dc96f4]
	[0x40dc964e]
	/usr/lib/pkgconfig/../../bin/mono [0x813b180]
	/usr/lib/pkgconfig/../../bin/mono(mono_runtime_invoke+0x27)
[0x80d63f7]
	/usr/lib/pkgconfig/../../bin/mono(mono_runtime_invoke_array+0x270)
[0x80d78c0]
	/usr/lib/pkgconfig/../../bin/mono(mono_message_invoke+0xc5)
[0x80d93d5]
	/usr/lib/pkgconfig/../../bin/mono [0x80a509f]
	/usr/lib/pkgconfig/../../bin/mono [0x80a58c9]
	/usr/lib/pkgconfig/../../bin/mono [0x8099fb2]
	/usr/lib/pkgconfig/../../bin/mono [0x80f5067]
	/usr/lib/pkgconfig/../../bin/mono [0x8113175]
	/lib/tls/libpthread.so.0 [0x400e5297]
	/lib/tls/libc.so.6(__clone+0x5e) [0x401e037e]


-----------------------------------------
Xavier Mauclaire
-------------------------------------------------------

 

-----Message d'origine-----
De : Tamas Szekeres [mailto:szekerest at gmail.com] Envoyé : lundi 19 juin 2006
17:30 À : Xavier Mauclaire Objet : Re: [UMN_MAPSERVER-USERS] Mapscript
,Mono, Apache and Linux : a great story

Xavier,

After looking into your code i've found private void
pMapSetSelection(shapeObj pShapeParcelle) as a potential candidate for
causing such a problem.

For adding inline layers you should use either the costructors with parent
objects (layerObj(mapObj map), classObj(layerObj layer), styleObj(classObj
parent_class)) or the insertxxx functions (insertLayer, insertClass,
insertStyle). Otherwise the layer will be added to your map twice.

If you would like to use insertLayer you should create a layerObj with null
parameter.

The main difference between the two methods is that insertXXX will duplicate
the object to be added so later you cannot use the original reference to set
the properies of the object added. You must use
getLayer() to get the reference of the layer added to the map.

If you intend to use solely the layerObj(mapObj map), classObj(layerObj
layer), styleObj(classObj parent_class) constructors (i consider it as the
preferred way) you have to use the latest CVS version (or the nightly build)
because we had a bug causing such memory problems:

http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=1743

For fixing the problem i have added the followings to csmodule.i

<code>
/***************************************************************************
***
 * Preventing to take ownership of the memory when constructing objects
 * with parent objects (causing nullreference exception, Bug 1743)
****************************************************************************
*/

%typemap(csconstruct, excode=SWIGEXCODE) layerObj(mapObj map) %{:
this($imcall, true) {
  if (map != null) this.swigCMemOwn = false;$excode } %}
%typemap(csconstruct, excode=SWIGEXCODE) classObj(layerObj layer) %{:
this($imcall, true) {
  if (layer != null) this.swigCMemOwn = false;$excode } %}
%typemap(csconstruct, excode=SWIGEXCODE) styleObj(classObj
parent_class) %{: this($imcall, true) {
  if (parent_class != null) this.swigCMemOwn = false;$excode } %} </code>

After making the patch (or using the CVS) i suggest the followings for
pMapSetSelection

<code>
			layerObj pLayer = new layerObj(pMapQuery);
			pLayer.type = MS_LAYER_TYPE.MS_LAYER_POLYGON;
			pLayer.addFeature(pShapeParcelle);
			pLayer.name="selection";
			classObj pClassItem = new classObj(pLayer);
			styleObj pStyle = new styleObj(pClassItem);
			pStyle.color.setRGB(-1,-1,-1);
			pStyle.outlinecolor.setRGB(0,0,0);
			pStyle.width = 4;
			pLayer.status = mapscript.MS_ON;
</code>

Would you make the suggested changes and notify me whether it works or not?
I think these problems may be responsible for the delete_layerObj crash, but
i am a bit uncertain about it will fix the getFeature crash. But let us go
further and see what happening.


Tamas



2006/6/19, Xavier Mauclaire <xavier.mauclaire at geoter.fr>:
> Tamas
>
> You will find next ths sources of my site You will understand that i 
> can't answer to the Mapserver mailing list with private sources. My 
> boss would be annoyed.
> These sources are not open source so i would ask you to not diffuse them.
>
> This project has been made with visual studio 2003
>
> regards
> Thanks in advance
>
>
> -----------------------------------------
> Xavier Mauclaire
> -------------------------------------------------------
>
>
>
> -----Message d'origine-----
> De : Tamas Szekeres [mailto:szekerest at gmail.com] Envoyé : lundi 19 
> juin 2006 13:41 À : Xavier Mauclaire Cc :
> MAPSERVER-USERS at lists.umn.edu Objet : Re: [UMN_MAPSERVER-USERS] 
> Mapscript ,Mono, Apache and Linux : a great story
>
> Xavier,
>
> I think the reason of the problem was happening outside of the code 
> fragment you have given before.
> Would you send an entire sample that produces this behaviour on your
system?
>
> Thanks,
>
> Tamas
>
>
> 2006/6/19, Xavier Mauclaire <xavier.mauclaire at geoter.fr>:
> >
> > Tamas
> > Thanks you for the answer,
> > Concerning the scratching problem under the Linux platform, what 
> > could you advise me to to ?
> >
> > Best regards
> >
> >
> > -----------------------------------------
> > Xavier Mauclaire
> > -------------------------------------------------------
> >
> >
> >
> > -----Message d'origine-----
> > De : Tamas Szekeres [mailto:szekerest at gmail.com] Envoyé : vendredi
> > 16 juin 2006 15:57 À : Xavier Mauclaire Cc :
> > MAPSERVER-USERS at lists.umn.edu Objet : Re: [UMN_MAPSERVER-USERS] 
> > Mapscript ,Mono, Apache and Linux : a great story
> >
> > Xavier,
> >
> >
> > > All the layerObj object i use  in my program are déclared in the 
> > > mapfile so i don't need to create layerObj from scratch using the
> > constructor.
> > > When you say that if a layerObj reference with a previously 
> > > released native memory segment, it may causing the error, what are 
> > > the consequences for my code ? Using the Dispose method is there 
> > > the solution to avoid this problem ?
> >
> > Most of the mapscript classes implement the IDisposable interface 
> > since they maintain unmanaged memory segments. It is a good practice 
> > to explicitly call Dispose (or by the using directive) if a newly 
> > created object is not needed any more. However you might want to 
> > maintain the mapObj reference for a longer period and the disposing 
> > will
> occur during the program destruction.
> > Getting an existing object reference (eg. as returned by
> > GetLayerByName) does not create a new object, so calling dispose is 
> > not needed.
> > All of the objects internally maintain a flag indicating if it 
> > should free the internal memory during the finalization. So calling 
> > Dispose in the previous case might also not cause any problems.
> >
> > So you may not have to take care much of these issues the existing 
> > problems may dedicated to unproper handling of this reference and 
> > considered to be fixed. However it is not so easy to locate the 
> > reason of the problem since the crash will be slipped out on a 
> > subsequent finalization or the program termination.
> >
> >
> > >
> > > How can i get CVS code ?
> >
> > http://mapserver.gis.umn.edu/development/cvs/
> >
> > using Tortoise CVS is fairly straightforward.
> >
> > > Why this code works well under windows and scratches under linux ?
> >
> > You may use different frameworks and CRT libraries. The problem may 
> > still exists but not manifested.
> >
> >
> > Tamas
> >
> >
>
>
>



More information about the mapserver-users mailing list