Segmentation fault adding a new layer with php-mapscript (4.6beta3)

Nicol Hermann mapserver at GEOWORLD.DE
Mon Jun 6 05:31:31 EDT 2005


Hi List,
i 'am trying to build a map from the scratch using php-mapscript and the
lastest cvs version.
Whenever i add a new layer with
$Layer = ms_newLayerObj($map);
I receive a segmentation fault.

gdb returns the following.
Is this a bug?

gdb php
GNU gdb 6.3-debian
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for
details.
This GDB was configured as "i386-linux"...Using host libthread_db
library "/lib/libthread_db.so.1".

(gdb) run test.php
Starting program: /usr/local/bin/php test.php
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 6289)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 6289)]
0x4114ea30 in layerObj_new (map=0x41f88008) at mapscript_i.c:410
410         map->layerorder[map->numlayers] = map->numlayers;
(gdb)

Attached a short test-script to reproduce the error

<?
  dl("../bin/php_mapscript_45.so");
  $map = ms_newMapObj('') or die('Unable to open mapfile.');
  $map->web->set ("imagepath","/home/nicol/public_html/mapserver/tmp/");
  $map -> web -> set ("imageurl", "/~nicol/mapserver/tmp/");
  $map -> set ("width", 300);
  $map -> set ("height", 300);  
$map->setExtent(5.86562681198,47.2757873535,15.0398788452,55.0556488037);

  $Layer = ms_newLayerObj($map);  // Line which causes the seg fault
  $Layer -> set("name","test");
  $Layer -> set("status", 1);
  $Layer ->
set("data","/home/nicol/public_html/mapserver/data/brd/brd");
  $Layer -> set("type", MS_LAYER_POLYGON );

  $poClass = ms_newClassObj($Layer);
  $styleObj = ms_newStyleObj($poClass);
  $styleObj -> color -> setRGB ( 192, 192, 192 );
  $styleObj -> outlinecolor -> setRGB ( 0 , 0, 0);
  $poClass -> set("name", "Germany");

  $img = @$map->draw();
  if (FALSE !== $img) {
        $url = $img->saveWebImage();
        $img->free();
        printf("<IMG SRC=%s>\n", $url);
  } else {
        printf ('Error');
  }
?>



More information about the mapserver-dev mailing list