Opened 20 years ago

Closed 18 years ago

Last modified 18 years ago

#840 closed defect (wontfix)

memory leaks in SLD parsing and application

Reported by: sgillies@… Owned by: assefa
Priority: high Milestone: 4.4 release
Component: MapServer C Library Version: 4.3
Severity: normal Keywords:
Cc:

Description

Am using valgrind 2.2 on Linux (FC2) to debug some Python mapscript code.
My script uses the test mapfile at mapserver/tests/test.map and essentially
generates SLDs for the layers of this mapfile and then re-applys the SLDs
to the same layers.  It's trivial, sure, but demonstrates some leaks.

==5321== 60 bytes in 3 blocks are definitely lost in loss record 52 of 88
==5321==    at 0x1B904A80: malloc (vg_replace_malloc.c:131)
==5321==    by 0x1C059498: FLTCreateFilterEncodingNode (mapogcfilter.c:1087)
==5321==    by 0x1C0593C8: FLTParseFilterEncoding (mapogcfilter.c:989)
==5321==    by 0x1C05C022: msSLDParseNamedLayer (mapogcsld.c:717)
==5321==    by 0x1C05BBE5: msSLDParseSLD (mapogcsld.c:513)
==5321==    by 0x1C05B587: msSLDApplySLD (mapogcsld.c:268)
==5321==    by 0x1BFCD986: layerObj_applySLD (mapscript_wrap.c:1264)
==5321==    by 0x1BFE9490: _wrap_layerObj_applySLD (mapscript_wrap.c:14770)
==5321==    by 0x80EA40C: PyCFunction_Call (in /usr/bin/python)
==5321==    by 0x805B3B6: PyObject_Call (in /usr/bin/python)
==5321==    by 0x80AB92A: (within /usr/bin/python)
==5321==    by 0x80A93C7: (within /usr/bin/python)
==5321== 
==5321== 
==5321== 80 bytes in 14 blocks are definitely lost in loss record 54 of 88
==5321==    at 0x1B904A80: malloc (vg_replace_malloc.c:131)
==5321==    by 0x1B9DA4EF: strdup (in /lib/tls/libc-2.3.3.so)
==5321==    by 0x1C05AE57: FLTGetBinaryComparisonExpresssion (mapogcfilter.c:2347)
==5321==    by 0x1C05A944: FLTGetMapserverExpression (mapogcfilter.c:2100)
==5321==    by 0x1C05C061: msSLDParseNamedLayer (mapogcsld.c:732)
==5321==    by 0x1C05BBE5: msSLDParseSLD (mapogcsld.c:513)
==5321==    by 0x1C05B587: msSLDApplySLD (mapogcsld.c:268)
==5321==    by 0x1BFCD986: layerObj_applySLD (mapscript_wrap.c:1264)
==5321==    by 0x1BFE9490: _wrap_layerObj_applySLD (mapscript_wrap.c:14770)
==5321==    by 0x80EA40C: PyCFunction_Call (in /usr/bin/python)
==5321==    by 0x805B3B6: PyObject_Call (in /usr/bin/python)
==5321==    by 0x80AB92A: (within /usr/bin/python)
==5321== 
==5321== 
==5321== 96 bytes in 6 blocks are definitely lost in loss record 55 of 88
==5321==    at 0x1B9053FD: calloc (vg_replace_malloc.c:176)
==5321==    by 0x1C1B3F5D: VSICalloc (in /usr/local/lib/libgdal.so.1.3.0)
==5321==    by 0x1C1ADC57: CPLCalloc (in /usr/local/lib/libgdal.so.1.3.0)
==5321==    by 0x1C1B169C: CPLCreateXMLNode (in /usr/local/lib/libgdal.so.1.3.0)
==5321==    by 0x1C1B1988: CPLCloneXMLTree (in /usr/local/lib/libgdal.so.1.3.0)
==5321==    by 0x1C05BFF1: msSLDParseNamedLayer (mapogcsld.c:705)
==5321==    by 0x1C05BBE5: msSLDParseSLD (mapogcsld.c:513)
==5321==    by 0x1C05B587: msSLDApplySLD (mapogcsld.c:268)
==5321==    by 0x1BFCD986: layerObj_applySLD (mapscript_wrap.c:1264)
==5321==    by 0x1BFE9490: _wrap_layerObj_applySLD (mapscript_wrap.c:14770)
==5321==    by 0x80EA40C: PyCFunction_Call (in /usr/bin/python)
==5321==    by 0x805B3B6: PyObject_Call (in /usr/bin/python)
==5321== 
==5321== 
...
==5321== 
==5321== 2096 bytes in 4 blocks are definitely lost in loss record 76 of 88
==5321==    at 0x1B904A80: malloc (vg_replace_malloc.c:131)
==5321==    by 0x1C05BB53: msSLDParseSLD (mapogcsld.c:497)
==5321==    by 0x1C05B587: msSLDApplySLD (mapogcsld.c:268)
==5321==    by 0x1BFCD986: layerObj_applySLD (mapscript_wrap.c:1264)
==5321==    by 0x1BFE9490: _wrap_layerObj_applySLD (mapscript_wrap.c:14770)
==5321==    by 0x80EA40C: PyCFunction_Call (in /usr/bin/python)
==5321==    by 0x805B3B6: PyObject_Call (in /usr/bin/python)
==5321==    by 0x80AB92A: (within /usr/bin/python)
==5321==    by 0x80A93C7: (within /usr/bin/python)
==5321==    by 0x80A9B5D: PyEval_EvalCodeEx (in /usr/bin/python)
==5321==    by 0x80AB34B: (within /usr/bin/python)
==5321==    by 0x80AB199: (within /usr/bin/python)

Here is the code of the script:
-------------------------------

        ...
        # Layers
        for layer, style in styledlayers:
            i = m.insertLayer(layer)
            l = m.getLayer(i)
            if style:
                l.applySLD(style, l.name)
            l.status = mapscript.MS_DEFAULT
           
        # Render
        return m.draw()

Change History (5)

comment:1 by dmorissette, 20 years ago

Cc: steve.lime@… added
Milestone: 4.4 release
Owner: changed from sdlime to assefa
Assigned to Assefa

comment:2 by sgillies@…, 20 years ago

Cc: warmerdam@… added

comment:3 by sgillies@…, 20 years ago

Frank, hope you don't mind, but I've cc'd you on this one since it also
involves your XML parser from GDAL.

comment:4 by sgillies@…, 18 years ago

Resolution: wontfix
Status: newclosed
this won't be fixed.

comment:5 by fwarmerdam, 18 years ago

I don't see how to reproduce this problem easily.  I do think something
vaguely similar to this was fixed some time ago. 

I did a quick check as follows in the msautotest/wxs directory:

vg mapserv
QUERY_STRING='map=wms_sld.map&SERVICE=WMS&VERSION=1.1.0&REQUEST=GetMap&LAYERS=road&sld_body=%3CStyledLayerDescriptor+version%3D%221.0.0%22%3E%0D%0A%3CNamedLayer%3E%0D%0A%3CName%3Eroad%3C%2FName%3E%0D%0A%3CUserStyle%3E%0D%0A%3CTitle%3Exxx%3C%2FTitle%3E%0D%0A%3CFeatureTypeStyle%3E%0D%0A%3CRule%3E%0D%0A%3CLineSymbolizer%3E%0D%0A%3CGeometry%3E%0D%0A%3CPropertyName%3Ecenter-line%3C%2FPropertyName%3E%0D%0A%3C%2FGeometry%3E%0D%0A%3CStroke%3E%0D%0A%3CCssParameter+name%3D%22stroke%22%3E%230000ff%3C%2FCssParameter%3E%0D%0A%3C%2FStroke%3E%0D%0A%3C%2FLineSymbolizer%3E%0D%0A%3C%2FRule%3E%0D%0A%3C%2FFeatureTypeStyle%3E%0D%0A%3C%2FUserStyle%3E%0D%0A%3C%2FNamedLayer%3E%0D%0A%3C%2FStyledLayerDescriptor%3E%0D%0A'
> /dev/null

And I didn't see any similar problems.

Note: See TracTickets for help on using tickets.