Segfault under Mapscript/Perl - Mapserver 4.4.0

Aaron Craig mercutio at POBOX.COM
Thu Dec 9 06:00:33 PST 2004


I'm getting a segmentation fault when I ask for a layer's name under Perl.

The following script (make sure you've got mapscript.pm installed, copy
the text into a file, chmod 0755 the file and run it off the command
line) demonstrates the error.

I've done a fresh build/install of mapserver 4.4.0 and the perl module
in mapscript/perl inside the 4.4.0 tarball.

Any insight would be appreciated.

 =============================================================================================

#!/usr/bin/perl

use strict;
use warnings;
use mapscript;
$| = 1;

my $sMapFileName = "test.map";

print "Creating test map file...";
MakeMapfile();
print "OK\n";

print "Creating map object...";
my $map = new mapscript::mapObj($sMapFileName) || die("Couldn't create
map instance");
print "OK\n";

my $nLayerCount = $map->{numlayers};
print "Getting information for $nLayerCount layer(s)\n";
for(my $i = 0; $i < $nLayerCount; $i++)
    {
    print "Getting layer at index $i...";
    my $lyr = $map->getLayer($i) || die("Couldn't get a layer for index
$i");
    print "OK\n";

    print "Getting layer name...";
    my $sLayerName = "";
    # comment out this line and the segfault disappears
    $sLayerName = $lyr->{name} || "No name";
    print "OK\n";

    print "$i: ";
    print "$lyr: ";
    print "$sLayerName\n";
    }

print "Cleaning up...";
unlink $sMapFileName;
print "OK\n";

sub MakeMapfile
    {
    open(OUT, ">$sMapFileName") || die("Couldn't create test mapfile: $!");

    print OUT qq{MAP
  NAME "Test"
  STATUS ON
  EXTENT -71.5 39.5 -63.0 46.0
  SIZE 504 385
  IMAGETYPE PNG
  UNITS DD

  OUTPUTFORMAT
    NAME PNG
    DRIVER "GD/PNG"
    MIMETYPE "image/png"
    IMAGEMODE RGB
  END

    SYMBOL
        TYPE ELLIPSE
        NAME "circle"
        POINTS 1 1 END
        FILLED TRUE
    END

    SYMBOL
        TYPE VECTOR
        NAME "plus"
        POINTS .5 0 .5 1 -99 -99 0 .5 1 .5 END
    END

    LAYER
        NAME "clickline"
        TYPE LINE
        STATUS OFF
    END

    LAYER
        NAME "clickline1"
        TYPE LINE
        STATUS OFF
    END

    LAYER
        NAME "clickline2"
        TYPE LINE
        STATUS OFF
    END

    LAYER
        NAME "clickline3"
        TYPE LINE
        STATUS OFF
    END

    LAYER
        NAME "clickline4"
        TYPE LINE
        STATUS OFF
    END

END
};

    close OUT;
    }

 ======================================================================================================

--
Aaron Craig
mercutio at pobox.com

===========================================================
Get Firefox!
http://www.spreadfirefox.com/?q=affiliates&id=0&t=1
===========================================================



More information about the MapServer-users mailing list