[Mapserver-dev] PHP Mapscript module and RegEx

Daniel Morissette dmorissette at dmsolutions.ca
Fri Sep 24 21:33:20 EDT 2004


Anthony Best wrote:
> 
> I'm looking into fixing the problem with PHP4s Bundled RegEx and Mapscript.
> 
> I've hacked the source to compile with mapserver using the system regex,
> while php is still using the builtin regex. The linking seems to be
> correct, however I'm uncertain that this is the correct path to fixing 
> this.
> 
> Is anyone else working on this?
> 
> What is the real problem that requires mapscript to use php's bundled 
> regex?
> 

The problem was that when you have PHP built with its bundled regex, and 
MapServer's core built with the system regex, you end up with two 
slightly different versions of the same library loaded in your symbol 
table at runtime. For instance both have the same struct regex_t but of 
different sizes. Both copies of the lib also have the same set of 
functions with the same names, but build for a different regex_t. What 
happens at runtime is that sometimes the wrong regex function gets 
called in the wrong context and pooouff... segmentation fault.

This same type of intermittent crash also happens if PHP and MapServer 
are compiled with different versions of other libs such as GD, libpng, 
etc. The key is that you should never have two different versions of the 
same library linked into the same executable either statically of via a 
shared library.


> Is there still a problem with thread-safety?
> 

There is at least one issue with the temporary filenames generated by 
imageObj.saveWebImage()... I'm not sure what it is, I just know that 
based on symptomsreported by users, there is a bug about that. There are 
quite likely others that will be found with more testing.

> I'm also getting the impression that mapscript is incorrectly using the
> php4 API. Is this true?
> 

I'm not sure to understand what you mean here?

> I'm willing to put the time and effort into fixing this issue (as well
> as other issues).
> 

Unfortunately the solution to this specific regex problem is not in 
MapServer's code: we need to either compile MapServer with PHP's regex, 
or find a way to force PHP to build with the system regex when built as 
an Apache DSO. For some reason that I don't undertand, the PHP 
developers have put an explicit test in the PHP configure script to 
prevent PHP from using the system regex when built as an Apache DSO... 
so we're kind of stuck.

Daniel
-- 
------------------------------------------------------------
  Daniel Morissette               dmorissette at dmsolutions.ca
  DM Solutions Group              http://www.dmsolutions.ca/
------------------------------------------------------------



More information about the mapserver-dev mailing list