Edit report at https://bugs.php.net/bug.php?id=64233&edit=1
ID: 64233
Comment by: andreas dot lindemann at de dot bp dot com
Reported by: andreas dot lindemann at de dot bp dot com
Summary: Soapserver::fault bus error on Solaris CLI/CGI/FPM
Status: Open
Type: Bug
Package: SOAP related
Operating System: Solaris 10
PHP Version: 5.4.11
Block user comment: N
Private report: N
New Comment:
Now with php 5.4.14 and still trying to narrow this down.
So far, I've narrowed it down to a single line of code.
The issue seems to be caused in ext/standard/html.c at the very end of
php_escape_html_entities_ex():
replaced[len] = '\0'; // This seems to be fine
*newlen = len; // <-- This line crashes PHP
return replaced;
}
It seems the issue occurs when accessing the "len" variable. If I add another
line just before the *newlen = len; line, i.e. for getting the value of "len"
out to the php logfile, PHP crashes on that new line as well:
Example (not a nice one):
php_error_docref0(NULL TSRMLS_CC, E_STRICT, "debug 1");
replaced[len] = '\0';
// Next line still goes to the log
php_error_docref0(NULL TSRMLS_CC, E_STRICT, "debug 2");
// Next line crashes PHP
php_error_docref0(NULL TSRMLS_CC, E_STRICT, (char*)len);
// This won't be executed:
*newlen = len;
// And we'll never see this:
php_error_docref0(NULL TSRMLS_CC, E_STRICT, "debug 3");
return replaced;
}
Any ideas?
Previous Comments:
------------------------------------------------------------------------
[2013-03-19 09:29:57] andreas dot lindemann at de dot bp dot com
Any chance of fixing or reproducing this?
If I can be of assistance, i.e. running some debug build to give more insight
into the issue or so, please let me know.
For now I've made a change to the soap extension to not run through the
php_escape_html_entities_ex function. This is probably neither a good idea nor
anywhere near a proper fix, considering that I've only got a very basic idea of
C, but at least it throws the SoapFaults correctly to the client and doesn't
crash the PHP process.
--- ext/soap/soap.c.orig 2013-01-16 08:10:30.000000000 +0100
+++ ext/soap/soap.c 2013-03-11 12:30:34.497971000 +0100
@@ -3881,7 +3881,8 @@
if (zend_hash_find(prop, "faultcode",
sizeof("faultcode"), (void**)&tmp) == SUCCESS) {
int new_len;
xmlNodePtr node = xmlNewNode(NULL,
BAD_CAST("faultcode"));
- char *str = php_escape_html_entities((unsigned
char*)Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), &new_len, 0, 0, NULL TSRMLS_CC);
+ char *str = (unsigned char*)Z_STRVAL_PP(tmp);
xmlAddChild(param, node);
if (fault_ns) {
xmlNsPtr nsptr = encode_add_ns(node,
fault_ns);
@@ -3906,7 +3907,8 @@
if (zend_hash_find(prop, "faultcode",
sizeof("faultcode"), (void**)&tmp) == SUCCESS) {
int new_len;
xmlNodePtr node = xmlNewChild(param, ns,
BAD_CAST("Code"), NULL);
- char *str = php_escape_html_entities((unsigned
char*)Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), &new_len, 0, 0, NULL TSRMLS_CC);
+ char *str = (unsigned char*)Z_STRVAL_PP(tmp);
node = xmlNewChild(node, ns, BAD_CAST("Value"),
NULL);
if (fault_ns) {
xmlNsPtr nsptr = encode_add_ns(node,
fault_ns);
------------------------------------------------------------------------
[2013-02-21 06:09:23] andreas dot lindemann at de dot bp dot com
This may be specific to Solaris 64bit.
I tried to reproduce on Linux 64bit (SuSE Linux Enterprise), but no issue there
as well.
However no problem to reproduce this on 5 of our Solaris Sparc servers, all are
showing the same bus error and backtrace.
------------------------------------------------------------------------
[2013-02-21 05:34:56] [email protected]
no luck to reproduce this on centOS.
------------------------------------------------------------------------
[2013-02-18 12:47:42] andreas dot lindemann at de dot bp dot com
Tried to reproduce on older versions: 5.4.6 fails with same error.
PHP 5.3.21 however works correctly:
$ ./php -v
PHP 5.3.21 (cli) (built: Feb 18 2013 13:16:03)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
$ ./php -f test_script.php
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode>
<faultstring>SoapServer::SoapServer(): Invalid parameters</faultstring></SOAP-
ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
Something must have been broken between 5.3.21 and 5.4.6+, maybe this helps
with
the investigation.
------------------------------------------------------------------------
[2013-02-18 10:06:50] andreas dot lindemann at de dot bp dot com
Note PHP has been compiled with 64bit.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=64233
--
Edit this bug report at https://bugs.php.net/bug.php?id=64233&edit=1