Re: Perplexing crash with 5.2.9+ php5ts.dll
| From: | Brad Waite | Date: | Sat, 25 Jul 2009 15:54:01 +0000 |
| Subject: | Re: Perplexing crash with 5.2.9+ php5ts.dll | ||
| References: | 1 2 3 4 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-29486@lists.php.net to get a copy of this message | ||
Richard Quadling wrote:
> OK, so far so good.
>
> Now create a simple PHP script which you can run at the command line
> which you think will cause the issue.
>
> If you can produce a simple test case, then allow us to run it to see
> if it is reproducible.
>
Okay, found the problem; it's with simplexml_load_string() and with some bad code.
simplexml_load_string() under 5.2.8 will return a proper SimpleXMLElement
object from a non-UTF-16-encoded bit of XML, even though the XML says that it
*is* encoded with UTF-16.
Under 5.2.9+, simplexml_load_string() tosses a warning and returns FALSE.
Apache was crashing because a poorly written SimpleXMLtoArray() function was
recursively calling itself without checking the arguments first. I suspect it
simply ran out of memory, but I didn't step through it enough times to verify.
Here's a bit of code that can reproduce the "problem":
$xmlstr = '<?xml version="1.0" encoding="utf-16"?><foo
xmlns="http://www.foo.com/service"><bar
name="foobar"></bar></foo>';
$xml = simplexml_load_string( $xmlstr, "SimpleXMLElement", LIBXML_NOCDATA );
Why the change in encoding-handling between the PHP versions? I can't see
anything in the 5.2.9 Changelog that would affect this.