Opened 21 years ago

Closed 21 years ago

#343 closed defect (fixed)

mapscript module crashes if ms_newshapefileobj is used

Reported by: m.haertel@… Owned by: dmorissette
Priority: high Milestone:
Component: MapScript-PHP Version: 4.0
Severity: major Keywords:
Cc:

Description

As soon as i use ms_newshapefileobj("path\filename",-1), the module
php_mapscript_37.dll crashes. Apache and php themselves are still operable.

It doesn't depend on the type of shapefile, the number of entries or the size of
the file. It happens every time.

I use Apache 2.43, PHP 4.3.2, Windows XP Pro and MapServer 3.7 (from
mapserver-3.7-win32-php4.3.0-gd2.zip) with php_mapscript_37.dll ($Revision:
1.143 $ $Date: 2003/02/04 15:39:43 $).

mapscript is parsed by the cgi-version of php and the mapscript module is
defined as "extension=php_mapscript_37.dll" in php.ini.
The extension is then loaded from the phtml-skript with dl(php_mapscript_37.dll).

Change History (5)

comment:1 by dmorissette, 21 years ago

Cc: assefa@… added
Status: newassigned
This works great for me on Linux (I'm not setup to test on Windows).

A few things to check:

1- You are using a development version that's several months old.  
   Can you please try this again with a more recent version and confirm that 
   the crash still happens.  For instance:  
http://www2.dmsolutions.ca/mapserver/dl/mapserver-4.0-beta1-win32-php4.3.2.zip

2- If you can still reproduce the crash with the latest version then can you
   please either provide a sample script/dataset to reproduce, or test against
   the following script which works for me (this is a modified version of the
   test_writeshape.phtml sample script that comes with the source distribution):


<?
//
// This example script shows how MapScript and the PHP DBase module
// can be used to create new Shapefile datasets.
//
// The optional DBase module must be loaded for this to work:
//  - On Windows, use dl("php3_dbase.dll")
//  - On Unix, configure PHP with the --with-dbase switch and recompile it.
//

// Load MapScript
dl("php_mapscript_40.so");

//----------------------------------------------------------
// produce shapefile
//----------------------------------------------------------

function createPoint( $x, $y, $programId )
{
    GLOBAL $shpFile, $dbfFile;

    // Create shape
    $oShp = ms_newShapeObj(MS_SHP_POINT);
    $oLine = ms_newLineObj();
    $oLine->addXY($x, $y);
    $oShp->add( $oLine );
    $shpFile->addShape($oShp);

    // Write attribute record
    dbase_add_record($dbfFile, array($programId));
}

$shpFname = "/tmp/shptest";
$shpFile = ms_newShapeFileObj( $shpFname, MS_SHP_POINT);
$dbfFile = dbase_create( $shpFname.".dbf", array(array("PROG_ID", "N", 5, 0)));

createPoint( 12, 34, 111);
createPoint( 22, 14, 222);
createPoint( 10, 20, 333);

echo "Shapes Created.<BR>";

//----------------------------------------------------------
// done... cleanup
//----------------------------------------------------------

$shpFile->free();
echo "Shape File ($shpFname) closed.<BR>";

dbase_close($dbfFile);
echo "Dbase file closed.<BR>";

//----------------------------------------------------------
// Try to reopen the file
//----------------------------------------------------------

echo "\n<br>Reopening file...<br>\n";

$srcFile = ms_newShapeFileObj( $shpFname, -1);
echo "\n$shpFname contains ".$srcFile->numshapes." shapes\n\n";
$srcFile->free();

?>

comment:2 by assefa, 21 years ago

Commnets comming from Bug 344. I ill mark bug 344 as a duplicate.

<?php
dl("php_mapscript_40.dll");

$oShapFile = ms_newShapeFileObj("c:/msapps/gmap/data/roads", -1);

?>

if roads does not exsit there is a crash happning in the msSHPCloseFile 
function.

I have tested this on Windows. 

comment:3 by assefa, 21 years ago

*** Bug 344 has been marked as a duplicate of this bug. ***

comment:4 by m.haertel@…, 21 years ago

I used the skript from Daniel Morissette  
(------- Additional Comment #1 From Daniel Morissette  2003-06-18 13:27 -------)

and even that skript crashes the mapscript module. 
So the crash has nothing to do with the existence of the shapefile and therefore
this bug report should not considered as a duplicate.

I will now try to use the mapserver version from this distribution:
http://www2.dmsolutions.ca/mapserver/dl/mapserver-4.0-beta1-win32-php4.3.2.zip

regards,

Michael

comment:5 by m.haertel@…, 21 years ago

Resolution: fixed
Status: assignedclosed
the Mapserver distribution from
http://www2.dmsolutions.ca/mapserver/dl/mapserver-4.0-beta1-win32-php4.3.2.zip
fixes the bug. 

I guess php_mapscript_37.dll does not completely work together with php 4.3.1
and 4.3.2 (I tried both versions and only encountered this mentioned error,
everything else worked fine), so you have to rely on php 4.3.1 if you use
mapscript 3.7.

greetings,

M. Härtel


Note: See TracTickets for help on using tickets.