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

Eric Bridger eric at gomoos.org
Tue May 4 16:00:25 EDT 2004


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.

======= free_test.pl ================
#!/usr/bin/perl

use strict;
use mapscript4;
#OR
#use mapscript42;

$ENV{MS_ERRORFILE} = '/tmp/mapserver4.log';

my $image_name = "free_test.png";
my $map = new mapscript4::mapObj("free_test.map");

if(!$map){
    warn "New mapObj() error: $mapscript4::ms_error->{message}\n";
}

my $img = $map->draw();

if(!$img){
    warn "map->draw() error: $mapscript4::ms_error->{message}\n";
}

$map->drawLabelCache($img);

$img->save($image_name);

# This causes core dump. w/o it works fine.
$img->free();

exit;

======== free_test.map =================

 
MAP
  STATUS ON
  EXTENT -71.50 39.5 -63.0 46.0 # MINX MINY MAXX MAXY
  SIZE 600 459
  IMAGETYPE PNG
  UNITS DD
  IMAGECOLOR 152 245 255
  OUTPUTFORMAT
    NAME PNG
    DRIVER "GD/PNG"
    MIMETYPE "image/png"
        # 24bit
    #IMAGEMODE RGB
        # 8 bit
    IMAGEMODE PC256
    EXTENSION "png"
  END
  PROJECTION
    "proj=latlong"
  END

LAYER
  NAME "gom_states"
  TYPE POLYGON
  STATUS DEFAULT
  DATA
"/home/www/gomoos.org/data/mapserver/vector/usgs/states/land_east"
  CLASS
    STYLE
      OUTLINECOLOR 162 193 194
      COLOR 255 255 204
        END
  END
  PROJECTION
    "proj=latlong"
  END
END

END


_______________________________________________
Mapserver-users mailing list
Mapserver-users at lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users




More information about the mapserver-dev mailing list