[Mapserver-dev] Perl Mapscript 4 $image->free() bug

Sean Gillies sgillies at frii.com
Tue May 4 17:31:48 EDT 2004


Eric Bridger wrote:

> Moving my Perl mapscript scripts to mapserver 4.0.2 and 4.2 beta1 I've
> discovered a problem with the imageObj->free() method.
> 
> I think I recall some recent posts with similiar problems on FreeBSD
> systems.
> 
> We are running: FreeBSD 4.8, Perl5.8.0
> Both:
> MapServer version 4.2-beta1 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG
> OUTPUT=WBMP SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER
> SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT
> INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE
> 
> MapServer version 4.0.2 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP
> SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT
> SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT INPUT=POSTGIS INPUT=OGR
> INPUT=GDAL INPUT=SHAPEFILE
> 
> --without-tiff GDAL 1.1.9
> 
> At first I thought it might be an Apache/mod_perl issue. Apache log
> showed messages like:
> httpd in free(): warning: junk pointer, too high to make sense
> mapserver.log showed occasional:
> Tue May  4 14:33:30 2004 - msFreeImage(): General error message. Unknown
> image type
> 
> But the short script and map file below, run from the command line
> produces ~ 900:
> perl in free(): warning: page is already free
> perl in free(): warning: junk pointer, too high to make sense
> perl in free(): warning: chunk is already free
> 
> Simple work around is to stop using $imageObj->free() which fixes the
> problem.
> 

[snip]

Eric,

There should be no need to free images.  I've made changes to mapscript
so that Perl's garbage collector sweeps up all instances of imageObj
and calls the DESTROY method (known as ~imageObj() in mapscript.i).
In fact, you shouldn't have to explicitly free any objects anymore.
Sorry that I haven't made this clear in the development docs.

If you don't want to wait for garbage collection, undef the instance
rather than calling its free() method.

cheers,
Sean






More information about the mapserver-dev mailing list