Opened 19 years ago

Closed 19 years ago

#1365 closed defect (duplicate)

[PHP MapScript] Seg Fault when using PHP 4.3.11 as a DSO

Reported by: dmorissette Owned by: mapserverbugs
Priority: high Milestone:
Component: MapScript-PHP Version: 4.5
Severity: normal Keywords:
Cc: bill@…

Description

Using the fix to bug 1354, we are able to build PHP MapScript using PHP's regex
for use with PHP as an Apache DSO.

It appears to work with ka-map, but unfortunately I get a seg. fault with the
GMap demo (gmap75.phtml):

==7477== Process terminating with default action of signal 11 (SIGSEGV)
==7477==  Access not within mapped region at address 0x1
==7477==    at 0x1BBA5252: add_property_string_ex (zend_API.c:979)
==7477==    by 0x1C01C0EE: _phpms_build_layer_object (php_mapscript.c:6363)
==7477==    by 0x1C0195C0: php3_ms_map_getLayerByName (php_mapscript.c:3892)
==7477==    by 0x1BBAFEB5: execute (zend_execute.c:1654)


I ran this in GDB and saw that the crash happens in a call to
$map->getLayerByName("road") when trying to set the name member of the PHP
object... somehow the layerObj (C struct) is invalid (and layer->name points to
an invalid location).

I'm not convinced this has a direct link with regex, but this is definitely a
problem with using PHP as a DSO.

Bill: have you been able to run complete apps with your php_mapscript built this
way? Did you experience any seg fault?

Change History (4)

comment:1 by bill@…, 19 years ago

Daniel,
I've got it map generated with 4.3.8 as a DSO.  Here is a URL for a map
generated by it:
http://mapshine.com/mockup/test_draw_map.phtml

I don't have a complete app up, because I haven't put it together yet (pending
getting PHP/Mapscript built).  My current app is javascript against CGI.

I have added this line to the above test:
$layer = $map->getLayerByName("AllParcels"); //which does exist

I get a segfault whether I'm through Apache (DSO) or on the command line:
php ./test_draw_map.phtml

I don't think this is a DSO issue: it would happend even in PHP in CGI mode.  It
may have something to do with the regex, but I'd be surprised.  It looks like
something's wrong with the getLayerByName call itself

comment:2 by bill@…, 19 years ago

Just a breadcrumb for you:
the reason for the segfault is that layerObj has two different sizeof()s when
called from mapfile.c or php_mapscript.c.

Could this be caused by the regex stuff: sure... but I don't see how yet.

comment:3 by bill@…, 19 years ago

dan, it is definitely related to the regex.  

It looks like it's going to be a bit more difficult than I thought yesterday. 
Because expressionObj holds it by value, and that gets included on both sides of
the fence, the #define needs be present on both sides.  However, PHP already
#defines it, which causes a problem.

This isn't a problem when things are held by reference.

I'll be available on IRC this afternoon/evening if you want to chat about it.  I
would resolve this as a dup of 1364.

comment:4 by dmorissette, 19 years ago

Resolution: duplicate
Status: newclosed
Closing as duplicate of bug 1354... let's move the discussion there.

*** This bug has been marked as a duplicate of 1354 ***
Note: See TracTickets for help on using tickets.