Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#2412 closed defect (fixed)

fix memory leaks

Reported by: tomkralidis Owned by: tomkralidis
Priority: normal Milestone: 5.2 release
Component: SOS Server Version: svn-trunk (development)
Severity: normal Keywords: sos
Cc: assefa, dmorissette, sdlime

Description

There are various memory leaks / issues when running msautotest/wxs/run_tests.py -valgrind ./msautotest/wxs/sos.map, which can be displayed when checking out the output in msautotest/wxs/results/sos_*.xml.vgrind.txt.txt.

Change History (8)

comment:1 by tomkralidis, 16 years ago

FYI first pass of changes in r7098

comment:2 by dmorissette, 16 years ago

Cc: dmorissette added
Owner: changed from mapserverbugs to tomkralidis

Tom, are you sure that r7098 is the correct fix? By removing the strdup() calls you actually make references in the sosParamsObj to memory owned by the cgiRequestObj... whether this is a good or a bad thing is arguable, but that makes me nervous in this specific case.

In addition to that, msSOSFreeParamsObj() will attempt to free the memory pointed to by sosparams->pszVersion and other members... but this memory is owned by the cgiRequestObj so it's bad bad bad to do that.

To be consistent with the way we do things elsewhere in MapServer, specifically the wfsParams data structure from which you probably copied the idea, I think you should revert your changes to strdup() all param names as before, and fix the leak by calling msSOSFreeParamsObj() everywhere it is needed.

comment:3 by sdlime, 16 years ago

Cc: sdlime added

in reply to:  2 ; comment:4 by tomkralidis, 16 years ago

Replying to dmorissette:

Tom, are you sure that r7098 is the correct fix? By removing the strdup() calls you actually make references in the sosParamsObj to memory owned by the cgiRequestObj... whether this is a good or a bad thing is arguable, but that makes me nervous in this specific case.

In addition to that, msSOSFreeParamsObj() will attempt to free the memory pointed to by sosparams->pszVersion and other members... but this memory is owned by the cgiRequestObj so it's bad bad bad to do that.

To be consistent with the way we do things elsewhere in MapServer, specifically the wfsParams data structure from which you probably copied the idea, I think you should revert your changes to strdup() all param names as before, and fix the leak by calling msSOSFreeParamsObj() everywhere it is needed.

Daniel: I'm confused; msSOSParseRequest in latest svn trunk does strdup() all param names. r7098 adds the strdup() calls, not remove them.

in reply to:  4 comment:5 by dmorissette, 16 years ago

Replying to tomkralidis:

Daniel: I'm confused; msSOSParseRequest in latest svn trunk does strdup() all param names. r7098 adds the strdup() calls, not remove them.

Oopps... sorry, I got into this ticket thinking it was about memory leaks only (as the ticket summary suggests) and didn't notice that the strdup() were actually added and not removed (i.e. fixing a double free instead of a leak).

I think attaching the valgrind output to the ticket, combined with a more complete description of the fixes in comment:1 would have helped... that's why I had to go view the changeset to figure what this "first pass of changes in r7098" comment meant exactly.

comment:6 by tomkralidis, 16 years ago

Resolution: fixed
Status: newclosed

Fixed a few of the more major leaks which came with the initial SOS 1.0.0 efforts. Closing for now. Can be reopened as required or new tickets against specific leaks.

comment:7 by assefa, 16 years ago

memory leak fixed in r7637.

comment:8 by tomkralidis, 16 years ago

A few more fixed in r7638

Note: See TracTickets for help on using tickets.