Opened 16 years ago

Closed 16 years ago

#2724 closed defect (fixed)

Resource leak

Reported by: brage Owned by: dmorissette
Priority: normal Milestone: 5.4 release
Component: MapScript-PHP Version: unspecified
Severity: normal Keywords:
Cc: sdlime

Description

If a php/mapscript application opens a layer with LayerObj::open() and forget to call Layerobj::close(), the resources are not cleaned up upon request end.

If for example the layer is a shapefile layer, the file descriptors are left open, and a long running apache process with a buggy php script may use all available file descriptors on a system, and in the worst case making the system crash.

I have no idea if this affects the other scripting languages, but a general fix might be to let freeLayer() in mapfile.c close the layer if it is open.

Attachments (1)

patch-resource-leak (536 bytes ) - added by brage 16 years ago.

Download all attachments as: .zip

Change History (4)

by brage, 16 years ago

Attachment: patch-resource-leak added

comment:1 by brage, 16 years ago

Component: MapServer C LibraryMapScript-PHP
Owner: changed from sdlime to mapserverbugs

comment:2 by dmorissette, 16 years ago

Cc: sdlime added
Milestone: 5.4 release
Owner: changed from mapserverbugs to dmorissette
Status: newassigned

This probably affects all MapScript versions. The proposed fix makes complete sense and should not have any unintended side-effect. I'll take care of this in the 5.4 (trunk) version.

comment:3 by dmorissette, 16 years ago

Resolution: fixed
Status: assignedclosed

Fixed in SVN trunk r7841.

I have reproduced the leak and verified that it's gone with Valgrind using a script that does repeated calls to

$map = ms_newMapObj("/path/to/test.map");
$layer = $map->getLayer("layername");
$layer->open();

$map = ms_newMapObj("/path/to/test.map");
$layer = $map->getLayer("layername");
$layer->open();

$map = ms_newMapObj("/path/to/test.map");
$layer = $map->getLayer("layername");
$layer->open();

...
Note: See TracTickets for help on using tickets.