Mapscript ,Mono, Apache and Linux : a great story

Xavier Mauclaire xavier.mauclaire at GEOTER.FR
Fri Jun 16 03:44:50 EDT 2006


Tamas
 
Thanks a lot for your answser.
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
?
 
How can i get CVS code ?
 
Concernig the number of result, i test the resultCacheObj.numresults value.
it is not enough ?
 
Why this code works well under windows and scratches under linux ?
 
regards
 

-----------------------------------------

Xavier Mauclaire

-------------------------------------------------------


 

 


  _____  

De : Tamas Szekeres [mailto:szekerest at gmail.com] 
Envoyé : vendredi 16 juin 2006 01:07
À : 'Xavier Mauclaire'; MAPSERVER-USERS at LISTS.UMN.EDU
Objet : RE: [UMN_MAPSERVER-USERS] Mapscript ,Mono, Apache and Linux : a
great story



Xavier,

 

All of the stack traces you reported represents me that you possibly have a
layerObj reference with a previoulsy released native memory segment.

This may occur if 2 or more layerObj references exclusively own the same
native memory and one of them is disposed or goes out of scope.

By this time i know one situation causing this problem is creating the layer
using the „layerObj(mapObj map)” constructor with non null map parameter.

(classobj(layerobj) and styleObj(classObj) are also suffer from this issue).
This problem was corrected in the current CVS HEAD.

 

So it would be important to know if you have some special handling of theese
objects in your application or all of theese object was created by parsing
the map file.

 

The given code fragment should theoretically work, however you should check
the number of the results before calling getResult.

 

 

Tamas

 

 

  _____  

From: Xavier Mauclaire [mailto:xavier.mauclaire at geoter.fr] 
Sent: Thursday, June 15, 2006 10:55 AM
To: 'Tamas Szekeres'; MAPSERVER-USERS at LISTS.UMN.EDU
Subject: RE: [UMN_MAPSERVER-USERS] Mapscript ,Mono, Apache and Linux : a
great story

 

Hi Tamas

 

You will find next information which may help.

Thanks in advance for your help

 

The problem is that the server scratches randomly occurs. However, i saw in
the logs (if the variable MALLOC_CHECK_ equals 0) the segmentation fault
appears a lot of time in GetFeature function. I saw in the mailing List
emails concerning this problem with Java.

 

You will find next : 

    1) piece of code c#

    2) mapfile used

    3) apache2 error_log file

 

 

system informations : 

    apache 2.2 (ia upgrade apache yesterday 2.0.54 to 2.2)

    Mono 1.1.13

    mod_mono 1.1.14

    mapserver 4.8.3 with mapscript csharp

    postgresql  8.1.3

    Postgis 1.1.1

    gdal 1.3.1

    geos 2.2.1

    gd-2.0.33

    libiconv 1.9.

 

Compilation options of Mapserver

 

./configure --with-gdal=/usr/local/bin/gdal-config
--with-ogr=/usr/local/bin/gdal-config
--with-postgis=/usr/local/pgsql/bin/pg_config --with-xpm=/usr/local/lib
--with-ming --with-png --with-jpeg --with-zlib --with-libiconv--without-tiff
--with-threads --with-geos=/usr/local/bin/geos-config --with-gif --with-proj
--with-gd=/usr/local -without-wms  

 

I'm really need any help. I don't know what to do.

I'm sure that architecture choices i've done are good So it has to be
working :-)   

 

regards

 

 

 

 

1) Piece of Code where 

 

 

private shapeObj localiser_parcelle(Double dX, Double dY, out String
zParcelleIdent){
shapeObj pShape = null;
zParcelleIdent = "";
int liRes ; 

 

   try {
    // recupération de la layer des parcelle
    // celle dont le nom est CONST_LAYERNAME_PARCELLE
    layerObj pLayerParcelle =
pMapQuery.getLayerByName(cConstantes.CONST_LAYERNAME_PARCELLE);
   
    if(pLayerParcelle != null){
     // creation du poitn de localisation
     pointObj pPoint = new pointObj(dX, dY,0.0,0.0 );

 

     // on recherche la parcelle au point cliqué
     pLayerParcelle.queryByPoint(pMapQuery,pPoint,mapscript.MS_SINGLE,0);
     resultCacheObj pRes =  pLayerParcelle.getResults();
     
     try{
      resultCacheMemberObj pResMember = null;

 

      if(pRes.numresults > 0) {
       //on zoom sur la selection courante
 
pMapQuery.setExtent(pRes.bounds.minx,pRes.bounds.miny,pRes.bounds.maxx,pRes.
bounds.maxy);     
 
       pLayerParcelle.open();
       try{
        // récupération de la première parcelle
        pResMember = pRes.getResult(0);
        pShape = pLayerParcelle.getFeature(pResMember.shapeindex,
pResMember.tileindex);
        if(pShape != null) {
       // récupération de l'identifiant de la parcellle
         Int32 liRang = -1;
         // recherche rang champs
         liRang = cRegInfos.SetLayerFieldRang(pLayerParcelle,
cRegInfo.CONST_IDPARCELLE);
         zParcelleIdent = pShape.getValue(liRang);
        } //end if 
       }finally{
        pLayerParcelle.close();
       } //e nd finally
      } //e nd if
     } finally {
      pRes.Dispose();
      pRes = null;
     } //e nd finally  
    } else
     throw new Exception("Couche des parcelles introuvable");     
   } finally{
   } //end finally 


return pShape;

} // end function

 

2) Mapfile 

 

#
#

 


MAP
NAME MAPFILE
STATUS ON
SHAPEPATH "/home/raster971/"
# Map image size. Change size as desired
SIZE 750 750
IMAGETYPE png 
# Extent based on full extent of QGIS view
EXTENT 635000 1768500  645000 1778700
SYMBOLSET "symbols/symbols.sym"
IMAGECOLOR  255 255 255
FONTSET "fonts/fonts.list"

 

 

 

#
# Start of web interface definition. Only the TEMPLATE parameter
# must be specified to display a map. See Mapserver documentation
#
WEB
 IMAGEPATH ""
 IMAGEURL "/tmp/"
END

 

 

 

OUTPUTFORMAT
  NAME png
  DRIVER "GD/PNG"
  MIMETYPE "image/png"
  EXTENSION "png"
  IMAGEMODE RGB
  TRANSPARENT OFF
END

 

 SCALEBAR
    IMAGECOLOR -1 -1 -1
    OUTLINECOLOR 0 0 0
    BACKGROUNDCOLOR 0 0 0
    LABEL
      COLOR 0 0 0
    END
    SIZE 150 5
    COLOR 255 255 255
    UNITS METERS
    INTERVALS 4
    TRANSPARENT on  
   STATUS EMBED 
   STYLE 0
    POSITION LR
  END

 

 

 

 

 


LAYER
  NAME limites_communales
  TYPE POLYGON 
  STATUS DEFAULT 
CONNECTION "user=postgres password=trucmuche dbname=pprsaintclaude
host=localhost port=5432"
CONNECTIONTYPE postgis
DATA "wkb_geometry from limites_communales"
    CLASS
     NAME "commune"
    END

 

END

 

 

 


LAYER
  NAME zonage_reglementaire
  TYPE POLYGON 
  STATUS DEFAULT 
CONNECTION "user=postgres password=trucmuche dbname=pprsaintclaude
host=localhost port=5432"
CONNECTIONTYPE postgis
TEMPLATE "rien.htm"

 

DATA "wkb_geometry from zonage_reglementaire"
    CLASSITEM "code_reg"

 

    CLASS
     NAME "0"
     EXPRESSION "0"    
       COLOR 255 255 255
     OUTLINECOLOR -1 -1 -1      
    END
    CLASS
     NAME "1"
     EXPRESSION "1"
     COLOR 160 224 255
     OUTLINECOLOR -1 -1 -1 
    END
   CLASS
     NAME "2"
     EXPRESSION "2"
     COLOR 64 192 255
     OUTLINECOLOR -1 -1 -1 
    END
    CLASS
     NAME "3"
     EXPRESSION "3"
     COLOR 0 0 255
     OUTLINECOLOR -1 -1 -1 
    END
    CLASS
     NAME "4"
     EXPRESSION "4"
     COLOR 255 128 128
     OUTLINECOLOR -1 -1 -1 
    END
     CLASS
     NAME "5"
     EXPRESSION "5"
     STYLE
      SYMBOL "hatch45"
    COLOR 255 0 0
      SIZE 6
      WIDTH 1
     END

 

    END
    CLASS
     NAME "6"
     EXPRESSION "6"
     COLOR 255 0 0
     OUTLINECOLOR -1 -1 -1 
    END
    CLASS
     NAME "7"
     EXPRESSION "7"
     COLOR 96 160 0
     OUTLINECOLOR -1 -1 -1 
    END
   CLASS
     NAME "8"
     EXPRESSION "8"
     COLOR 160 224 255
     OUTLINECOLOR 0 255 255 
    END

 


END

 

LAYER
  NAME parcelles
  TYPE POLYGON 
  STATUS DEFAULT 
  
TEMPLATE "rien.htm"
CONNECTION "user=postgres password=trucmuche dbname=pprsaintclaude
host=localhost port=5432"
CONNECTIONTYPE postgis
DATA "wkb_geometry from parcelles"
  CLASS
    NAME "parcelle"
    COLOR -1 -1 -1
    OUTLINECOLOR 0 0 0 
  END

 

END

  

END # Map File

 

3) Logs in the apache error_log file

 

The following logs show error information of two scratches (After each
segmentation fault i have to restart apache). You can notice the the error
does not appears et the same location (Garbage collector of mono ??) 

 

 

[Fri Jun 16 10:41:41 2006] [notice] Apache/2.2.0 (Unix) mod_mono/1.1.14
configured -- resuming normal operations
Another mod-mono-server with the same arguments is already running.
Another mod-mono-server with the same arguments is already running.
Another mod-mono-server with the same arguments is already running.
Another mod-mono-server with the same arguments is already running.

 

=================================================================
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:delete_layerObj
(System.Runtime.InteropServices.HandleRef) <0x4>
in (wrapper managed-to-native) mapscriptPINVOKE:delete_layerObj
(System.Runtime.InteropServices.HandleRef) <0xfe880ea1>
in layerObj:Dispose () <0x41>
in layerObj:Finalize () <0xe>
in (wrapper runtime-invoke) System.Object:runtime_invoke_void
(object,intptr,intptr,intptr) <0xc68dba2f>

 

Native stacktrace:

 

 /usr/lib/pkgconfig/../../bin/mono(mono_handle_native_sigsegv+0xbb)
[0x814ee2b]
 /usr/lib/pkgconfig/../../bin/mono [0x813b2cf]
 [0xffffe440]
 /usr/local/lib/libmapscript.so(msFree+0x21) [0x41a4c951]
 /usr/local/lib/libmapscript.so(freeLayer+0x35) [0x41a50655]
 /usr/local/lib/libmapscript.so(CSharp_delete_layerObj+0x7f) [0x41a28fef]
 [0x42fdeb6c]
 [0x4185f9aa]
 [0x4185f947]
 [0x4185f779]
 /usr/lib/pkgconfig/../../bin/mono [0x813b180]
 /usr/lib/pkgconfig/../../bin/mono(mono_runtime_invoke+0x27) [0x80d63f7]
 /usr/lib/pkgconfig/../../bin/mono [0x80d2dc5]
 /usr/lib/pkgconfig/../../bin/mono [0x8114cc7]
 /usr/lib/pkgconfig/../../bin/mono [0x80d3b7c]
 /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]
[Fri Jun 16 10:43:55 2006] [notice] caught SIGTERM, shutting down
[Fri Jun 16 10:43:56 2006] [notice] Apache/2.2.0 (Unix) mod_mono/1.1.14
configured -- resuming normal operations
Another mod-mono-server with the same arguments is already running.
Another mod-mono-server with the same arguments is already running.
Another mod-mono-server with the same arguments is already running.
Another mod-mono-server with the same arguments is already running.

 

=================================================================
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:localiser_parcelle (double,double,string&)
<0x1df>
in siteflash.GetParcelleReglement:ProcessRequest (System.Web.HttpContext)
<0x56c>
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[]) <0xfffee09e>
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/pgsql/lib/libpq.so.4(pqResultAlloc+0xd5) [0x42025f25]
 /usr/local/pgsql/lib/libpq.so.4(pqParseInput3+0x2b7) [0x4202e677]
 /usr/local/pgsql/lib/libpq.so.4 [0x42026b04]
 /usr/local/pgsql/lib/libpq.so.4(PQgetResult+0x9d) [0x4202810d]
 /usr/local/pgsql/lib/libpq.so.4 [0x420282be]
 /usr/local/lib/libmapscript.so(msPOSTGISLayerRetrievePGVersion+0x43)
[0x41ab70e3]
 /usr/local/lib/libmapscript.so(msPOSTGISLayerRetrievePK+0x31) [0x41ab7331]
 /usr/local/lib/libmapscript.so [0x41ab7aa4]
 /usr/local/lib/libmapscript.so(msPOSTGISLayerGetShape+0x7d) [0x41ab7e5d]
 /usr/local/lib/libmapscript.so(msPOSTGISLayerGetShapeVT+0x23) [0x41ab85b3]
 /usr/local/lib/libmapscript.so(msLayerGetShape+0x2e) [0x41a6db3e]
 /usr/local/lib/libmapscript.so(CSharp_layerObj_getFeature+0x46)
[0x41a29636]
 [0x41861db2]
 [0x41861cd0]
 [0x41860ea8]
 [0x4186048d]
 [0x416f6421]
 [0x416f52a8]
 [0x416f1668]
 [0x416f1549]
 [0x41251854]
 [0x41251385]
 [0x41251343]
 [0x41250544]
 [0x41235535]
 [0x41234c9c]
 [0x41234a7b]
 [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

-------------------------------------------------------


 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20060616/bf3ca39e/attachment.html


More information about the mapserver-users mailing list