[MacPorts] #14063: PHP 5.2.5_1 crashes on XSLTProcessor::importStylesheet
#14063: PHP 5.2.5_1 crashes on XSLTProcessor::importStylesheet -----------------------------------+---------------------------------------- Reporter: peter@no-nonsense.org | Owner: macports-tickets@lists.macosforge.org Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 1.6.0 Keywords: | -----------------------------------+---------------------------------------- When I run this little PHP script with my MacPorts Apache2/PHP 5.2.5_1 (both the latest versions available in the ports): {{{ <?php $stylesheet = new DOMDocument(); $stylesheet->loadXML('<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> </xsl:stylesheet> '); $processor = new XSLTProcessor(); $processor->importStylesheet($stylesheet); echo "jow"; }}} Apache segfaults: [Thu Jan 24 22:51:35 2008] [notice] child pid 24505 exit signal Segmentation fault (11) The strange thing is, when I change the echo from a simple "jow" to something like "never gets here :(" the script sometimes doesn't segfault. When I remove the echo however it always segfaults. Running the same script using the cli php (the MacPorts php binary, not the built-in Leopard PHP binary), doesn't segfault. Based on this post http://www.nabble.com/Problem-with-PHP-and-libxslt- td15000461.html, I did a reinstall of libxml2, libxslt and php5, but this didn't help either. Ofcourse in real-life my code is a bit more complex, but I got it reduced to this small example. My real XSLT stylesheet ofcourse isn't empty. -- Ticket URL: <http://trac.macosforge.org/projects/macports/ticket/14063> MacPorts </projects/macports> Ports system for Mac OS
#14063: PHP 5.2.5_1 crashes on XSLTProcessor::importStylesheet ------------------------------------+--------------------------------------- Reporter: peter@no-nonsense.org | Owner: macports-tickets@lists.macosforge.org Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 1.6.0 Resolution: | Keywords: ------------------------------------+--------------------------------------- Comment (by peter@no-nonsense.org): Using gdb I was able to generate a backtrace: Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0xfffffff4 0x914fc2af in szone_free () (gdb) bt #0 0x914fc2af in szone_free () #1 0x914fb9ed in free () #2 0x93635aba in xmlFreeNodeList () #3 0x936359c4 in xmlFreeNodeList () #4 0x0195d575 in xmlFreeDoc () #5 0x01002913 in php_libxml_decrement_doc_ref () #6 0x01055920 in dom_objects_free_storage () #7 0x012afc4a in zend_objects_store_del_ref_by_handle () #8 0x012afc67 in zend_objects_store_del_ref () #9 0x01282ee8 in _zval_ptr_dtor () #10 0x0129bb77 in zend_hash_apply_deleter () #11 0x0129bf9e in zend_hash_reverse_apply () #12 0x0128211f in shutdown_destructors () #13 0x012913d6 in zend_call_destructors () #14 0x012495f3 in php_request_shutdown () #15 0x01328a32 in php_handler () #16 0x000028b8 in ap_run_handler () #17 0x00002dc7 in ap_invoke_handler () #18 0x00027bae in ap_process_request () #19 0x00024578 in ap_process_http_connection () #20 0x000104f8 in ap_run_process_connection () #21 0x0002c320 in child_main () #22 0x0002c5fa in make_child () #23 0x0002d950 in ap_mpm_run () #24 0x00009060 in main () -- Ticket URL: <http://trac.macosforge.org/projects/macports/ticket/14063#comment:1> MacPorts </projects/macports> Ports system for Mac OS
#14063: PHP 5.2.5_1 crashes on XSLTProcessor::importStylesheet ------------------------------------+--------------------------------------- Reporter: peter@no-nonsense.org | Owner: macports-tickets@lists.macosforge.org Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 1.6.0 Resolution: | Keywords: ------------------------------------+--------------------------------------- Comment (by peter@no-nonsense.org): Hmmm {{{ Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0xfffffff4 0x914fc2af in szone_free () (gdb) bt #0 0x914fc2af in szone_free () #1 0x914fb9ed in free () #2 0x93635aba in xmlFreeNodeList () #3 0x936359c4 in xmlFreeNodeList () #4 0x0195d575 in xmlFreeDoc () #5 0x01002913 in php_libxml_decrement_doc_ref () #6 0x01055920 in dom_objects_free_storage () #7 0x012afc4a in zend_objects_store_del_ref_by_handle () #8 0x012afc67 in zend_objects_store_del_ref () #9 0x01282ee8 in _zval_ptr_dtor () #10 0x0129bb77 in zend_hash_apply_deleter () #11 0x0129bf9e in zend_hash_reverse_apply () #12 0x0128211f in shutdown_destructors () #13 0x012913d6 in zend_call_destructors () #14 0x012495f3 in php_request_shutdown () #15 0x01328a32 in php_handler () #16 0x000028b8 in ap_run_handler () #17 0x00002dc7 in ap_invoke_handler () #18 0x00027bae in ap_process_request () #19 0x00024578 in ap_process_http_connection () #20 0x000104f8 in ap_run_process_connection () #21 0x0002c320 in child_main () #22 0x0002c5fa in make_child () #23 0x0002d950 in ap_mpm_run () #24 0x00009060 in main () }}} More readable. :) -- Ticket URL: <http://trac.macosforge.org/projects/macports/ticket/14063#comment:2> MacPorts </projects/macports> Ports system for Mac OS
#14063: PHP 5.2.5_1 crashes on XSLTProcessor::importStylesheet ------------------------------------+--------------------------------------- Reporter: peter@no-nonsense.org | Owner: ryandesign@macports.org Type: defect | Status: new Priority: Normal | Milestone: Port Bugs Component: ports | Version: 1.6.0 Resolution: | Keywords: ------------------------------------+--------------------------------------- Changes (by ryandesign@macports.org): * owner: macports-tickets@lists.macosforge.org => ryandesign@macports.org * milestone: => Port Bugs Comment: Assigning to maintainer of php5 (me!). I will see if I can reproduce this on my system. -- Ticket URL: <http://trac.macosforge.org/projects/macports/ticket/14063#comment:3> MacPorts </projects/macports> Ports system for Mac OS
#14063: PHP 5.2.5_1 crashes on XSLTProcessor::importStylesheet ------------------------------------+--------------------------------------- Reporter: peter@no-nonsense.org | Owner: ryandesign@macports.org Type: defect | Status: new Priority: Normal | Milestone: Port Bugs Component: ports | Version: 1.6.0 Resolution: | Keywords: ------------------------------------+--------------------------------------- Comment (by jonasmunk@mac.com): Hi, I was am the one who psoted http://www.nabble.com/Problem-with-PHP- and-libxslt-td15000461.html Is there any progress or is there any way I can help? -- Ticket URL: <http://trac.macosforge.org/projects/macports/ticket/14063#comment:4> MacPorts </projects/macports> Ports system for Mac OS
#14063: PHP 5.2.5_1 crashes on XSLTProcessor::importStylesheet ------------------------------------+--------------------------------------- Reporter: peter@no-nonsense.org | Owner: ryandesign@macports.org Type: defect | Status: new Priority: Normal | Milestone: Port Bugs Component: ports | Version: 1.6.0 Resolution: | Keywords: ------------------------------------+--------------------------------------- Comment (by dp macports@oxidized.org): I suspect that I'm having a related problem. In my case, libxml2 from MacPorts defines the xmlURI struct with one more element than the libxml2 from Mac OS X. For some reason, it uses the xmlCreateURI function from /usr/lib/libxml2.dylib instead of the xmlCreateURI function from /opt/local/lib/libxml2.dylib. This results in the last element of the xmlURI struct not getting initialized to NULL, so that when the struct is destroyed, the code attempts to free the wild pointer. Bang, dead. Seems like /opt/local/lib/libxml2.dylib (9.0.0) should have a higher compatibility version than /usr/lib/libxml2.dylib (9.0.0). This doesn't always fail because sometimes the correct version of the function is called. I downgraded to libxml2 2.6.28 and the problem seems to have gone away. Note that this is still newer than the version that Apple ships, so there is still a chance of an incompatibility. At least in my case, this is arguably a libxml2 bug, not a PHP bug. -- Ticket URL: <http://trac.macosforge.org/projects/macports/ticket/14063#comment:5> MacPorts </projects/macports> Ports system for Mac OS
#14063: PHP 5.2.5_1 crashes on XSLTProcessor::importStylesheet ------------------------------------+--------------------------------------- Reporter: peter@no-nonsense.org | Owner: ryandesign@macports.org Type: defect | Status: new Priority: Normal | Milestone: Port Bugs Component: ports | Version: 1.6.0 Resolution: | Keywords: ------------------------------------+--------------------------------------- Comment (by peter@no-nonsense.org): Just tried with php5-devel (5.2.6 RC1), no luck. How can I downgrade libxml2 to check if this fixes my problem? Does the port command support specifying a version you want to install? -- Ticket URL: <http://trac.macosforge.org/projects/macports/ticket/14063#comment:6> MacPorts </projects/macports> Ports system for Mac OS
#14063: PHP 5.2.5_1 crashes on XSLTProcessor::importStylesheet ------------------------------------+--------------------------------------- Reporter: peter@no-nonsense.org | Owner: ryandesign@macports.org Type: defect | Status: new Priority: Normal | Milestone: Port Bugs Component: ports | Version: 1.6.0 Resolution: | Keywords: ------------------------------------+--------------------------------------- Comment (by peter@no-nonsense.org): I modified my local libxml2 Portfile so that it installs libxml2. I forcefully uninstalled libxml2. Installed the older verion (2.6.28), uninstalled php5-devel, reinstalled php5-devel (after cleaning ofcourse) but I still have the same problem :( -- Ticket URL: <http://trac.macosforge.org/projects/macports/ticket/14063#comment:7> MacPorts </projects/macports> Ports system for Mac OS
#14063: PHP 5.2.5_1 crashes on XSLTProcessor::importStylesheet ------------------------------------+--------------------------------------- Reporter: peter@no-nonsense.org | Owner: ryandesign@macports.org Type: defect | Status: new Priority: Normal | Milestone: Port Bugs Component: ports | Version: 1.6.0 Resolution: | Keywords: ------------------------------------+--------------------------------------- Comment (by ryandesign@macports.org): Replying to [comment:5 dp macports@oxidized.org]:
I suspect that I'm having a related problem. In my case, libxml2 from MacPorts defines the xmlURI struct with one more element than the libxml2 from Mac OS X. For some reason, it uses the xmlCreateURI function from /usr/lib/libxml2.dylib instead of the xmlCreateURI function from /opt/local/lib/libxml2.dylib. This results in the last element of the xmlURI struct not getting initialized to NULL, so that when the struct is destroyed, the code attempts to free the wild pointer. Bang, dead.
Seems like /opt/local/lib/libxml2.dylib (9.0.0) should have a higher compatibility version than /usr/lib/libxml2.dylib (9.0.0).
Cc'ing maintainer of libxml2 since apparently a bug needs to be reported to the developers of libxml: `/opt/local/lib/libxml2.dylib` (version 9.31.0) and `/usr/lib/libxml2.dylib` (version 9.16.0 (on Mac OS X 10.4.11)) claim to have the same compatibility version (9.0.0) though they are incompatible because they define the `xmlURI` struct differently. Here's the relevant diff from the source: {{{ $ diff -bu libxml2-2.6.{16,31}/include/libxml/uri.h --- libxml2-2.6.16/include/libxml/uri.h 2004-06-07 16:33:11.000000000 -0500 +++ libxml2-2.6.31/include/libxml/uri.h 2007-04-26 03:31:34.000000000 -0500 @@ -23,6 +23,10 @@ * * A parsed URI reference. This is a struct containing the various fields * as described in RFC 2396 but separated for further processing. + * + * Note: query is a deprecated field which is incorrectly unescaped. + * query_raw takes precedence over query if the former is set. + * See: http://mail.gnome.org/archives/xml/2007-April/thread.html#00127 */ typedef struct _xmlURI xmlURI; typedef xmlURI *xmlURIPtr; @@ -34,9 +38,10 @@ char *user; /* the user part */ int port; /* the port number */ char *path; /* the path string */ - char *query; /* the query string */ + char *query; /* the query string (deprecated - use with caution) */ char *fragment; /* the fragment identifier */ int cleanup; /* parsing potentially unclean URI */ + char *query_raw; /* the query string (as it appears in the URI) */ }; /* [snip] }}} Replying to [comment:6 peter@no-nonsense.org]:
How can I downgrade libxml2 to check if this fixes my problem? Does the port command support specifying a version you want to install?
No it does not. I see you already found how to do this, and I'm sorry to hear it did not help in your case, but for others who may want to try it: To get an older version, [browser:trunk/dports browse the repository] to find the port you want, then use the Revision Log link in the upper right to find the older version of the portfile that you want to install. For example, here's the portfile for [browser:trunk/dports/textproc/libxml2/Portfile@26074 libxml2 @2.6.28_1]. Download this to disk using the Original Format link at the bottom of the page. Then use the Terminal to `cd` to the directory where you downloaded the portfile and type "`port install`". If the port had any patchfiles you would also need to grab all of them from the same revision, but libxml2 doesn't have any. -- Ticket URL: <http://trac.macosforge.org/projects/macports/ticket/14063#comment:8> MacPorts </projects/macports> Ports system for Mac OS
#14063: PHP 5.2.5_1 crashes on XSLTProcessor::importStylesheet ------------------------------------+--------------------------------------- Reporter: peter@no-nonsense.org | Owner: ryandesign@macports.org Type: defect | Status: new Priority: Normal | Milestone: Port Bugs Component: ports | Version: 1.6.0 Resolution: | Keywords: ------------------------------------+--------------------------------------- Changes (by ryandesign@macports.org): * cc: cedric.luthi@gmail.com (added) -- Ticket URL: <http://trac.macosforge.org/projects/macports/ticket/14063#comment:9> MacPorts </projects/macports> Ports system for Mac OS
#14063: PHP 5.2.5_1 crashes on XSLTProcessor::importStylesheet ------------------------------------+--------------------------------------- Reporter: peter@no-nonsense.org | Owner: ryandesign@macports.org Type: defect | Status: new Priority: Normal | Milestone: Port Bugs Component: ports | Version: 1.6.0 Resolution: | Keywords: ------------------------------------+--------------------------------------- Comment (by dp macports@oxidized.org): Replying to [comment:7 peter@no-nonsense.org]:
Installed the older verion (2.6.28), uninstalled php5-devel, reinstalled php5-devel (after cleaning ofcourse) but I still have the same problem :(
I ran into a further problem, again related to libxml2. This time, it was in xmlFreeDoc() (I think). I downgraded libxml2 and libxslt to: * libxml2 @2.6.16_0 * libxslt @1.1.12_0 That solved my new problem. Note that the libxml2 version there is the same version that Apple ships (try `/usr/bin/xml2-config --version`). Sorry I don't have more details; I didn't really have time to track it down. -- Ticket URL: <http://trac.macosforge.org/projects/macports/ticket/14063#comment:10> MacPorts </projects/macports> Ports system for Mac OS
#14063: PHP 5.2.5_1 crashes on XSLTProcessor::importStylesheet ------------------------------------+--------------------------------------- Reporter: peter@no-nonsense.org | Owner: ryandesign@macports.org Type: defect | Status: new Priority: Normal | Milestone: Port Bugs Component: ports | Version: 1.6.0 Resolution: | Keywords: ------------------------------------+--------------------------------------- Comment (by peter@no-nonsense.org): I'm using the Entropy PHP 5.2.5 Beta 6 (http://www.entropy.ch/phpbb2/viewtopic.php?t=2945&start=75) version for now (using the default Apache included in Leopard) which seems to work fine. It uses libxml2 version 2.6.30 and libxslt version 1.1.22. Strange that those don't seem to crash... -- Ticket URL: <http://trac.macosforge.org/projects/macports/ticket/14063#comment:11> MacPorts </projects/macports> Ports system for Mac OS
#14063: PHP 5.2.5_1 crashes on XSLTProcessor::importStylesheet ------------------------------------+--------------------------------------- Reporter: peter@no-nonsense.org | Owner: ryandesign@macports.org Type: defect | Status: new Priority: Normal | Milestone: Port Bugs Component: ports | Version: 1.6.0 Resolution: | Keywords: ------------------------------------+--------------------------------------- Comment (by guglielmo.celata@gmail.com): Replying to [comment:10 dp macports@oxidized.org]:
Replying to [comment:7 peter@no-nonsense.org]:
Installed the older verion (2.6.28), uninstalled php5-devel, reinstalled php5-devel (after cleaning ofcourse) but I still have the same problem :(
I ran into a further problem, again related to libxml2. This time, it was in xmlFreeDoc() (I think). I downgraded libxml2 and libxslt to: * libxml2 @2.6.16_0 * libxslt @1.1.12_0
That solved my new problem. Note that the libxml2 version there is the same version that Apple ships (try `/usr/bin/xml2-config --version`). I had the same problem on an OSX 10.5, with libxml2 2.6.31 and libxslt 1.1.22, apache2 and php5, everything installed with macports. A simple php script was correctly executed with the CLI, and a segmentation fault came out when using the libphp5.so. I downgraded as you suggested and things went back to normal.
-- Ticket URL: <http://trac.macosforge.org/projects/macports/ticket/14063#comment:12> MacPorts </projects/macports> Ports system for Mac OS
participants (1)
-
MacPorts