Bug #64017 [Opn]: php_libxml_initialize overwrites global entity loader
| From: | cataphract@php.net | Date: | Fri, 18 Jan 2013 11:56:31 +0000 |
| Subject: | Bug #64017 [Opn]: php_libxml_initialize overwrites global entity loader | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-176097@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64017&edit=1
ID: 64017
Updated by: cataphract@php.net
Reported by: piotrek dot pokora at gmail dot com
Summary: php_libxml_initialize overwrites global entity
loader
Status: Open
Type: Bug
Package: CGI/CLI related
Operating System: Linux/Debian
PHP Version: 5.4.11
Block user comment: N
Private report: N
New Comment:
I don't think that's the problem. Your frame #8:
#8 0x000000000045681b in _php_libxml_pre_ext_ent_loader (URL=0xea1990
"/app/libgda/share/libgda-4.0/dtd/libgda-array.dtd", ID=0x0,
context=0xe9e0b0) at /app/php-5.4.8/ext/libxml/libxml.c:694
indicates PHP is using the original entity loader:
694 return _php_libxml_default_entity_loader(URL, ID, context);
precisely because PHP refuses to use the custom entity loader except if all the modules have gone
though module AND request init. _php_libxml_default_entity_loader is set here:
730PHP_LIBXML_API void php_libxml_initialize(void)
731{
732 if (!_php_libxml_initialized) {
733 /* we should be the only one's to ever init!! */
734 xmlInitParser();
735
736 _php_libxml_default_entity_loader = xmlGetExternalEntityLoader();
737 xmlSetExternalEntityLoader(_php_libxml_pre_ext_ent_loader);
So my guess is the problem is elsewhere. Namely, this commit:
https://github.com/php/php-src/commit/d8bddb966563
xmlParserInputBufferCreateFilenameDefault() is now called on module init and not on request init in
some SAPIs. Other modules that use libxml but happen to run minit after the libxml PHP module may
have some trouble as php_libxml_input_buffer_create_filename() may not be ready to be executed yet.
Previous Comments:
------------------------------------------------------------------------
[2013-01-18 11:28:20] piotrek dot pokora at gmail dot com
Description:
------------
php_libxml_initialize function in ext/libxml sets global entity loader via
xmlSetExternalEntityLoader(_php_libxml_pre_ext_ent_loader). This affects any library which is loaded
implicitly during loading phase and triggers segmentation fault.
Gdb output:
Program received signal SIGSEGV, Segmentation fault.
_zend_hash_index_update_or_next_insert (ht=0xd1b910, h=0, pData=<value optimized out>,
nDataSize=16, pDest=0x0, flag=1)
at /app/php-5.4.8/Zend/zend_hash.c:385
385 /app/php-5.4.8/Zend/zend_hash.c: No such file or directory.
in /app/php-5.4.8/Zend/zend_hash.c
(gdb) bt
#0 _zend_hash_index_update_or_next_insert (ht=0xd1b910, h=0, pData=<value optimized out>,
nDataSize=16, pDest=0x0, flag=1)
at /app/php-5.4.8/Zend/zend_hash.c:385
#1 0x000000000068f600 in zend_list_insert (ptr=<value optimized out>, type=<value
optimized out>) at /app/php-5.4.8/Zend/zend_list.c:46
#2 0x000000000068f61e in zend_register_resource (rsrc_result=0x0, rsrc_pointer=0x7ffff7fad2c8,
rsrc_type=-134556984)
at /app/php-5.4.8/Zend/zend_list.c:98
#3 0x00000000006392d6 in php_stream_context_alloc () at /app/php-5.4.8/main/streams/streams.c:2199
#4 0x0000000000455035 in php_libxml_streams_IO_open_wrapper (filename=0xea1990
"/app/libgda/share/libgda-4.0/dtd/libgda-array.dtd",
mode=0xa71434 "rb", read_only=1) at /app/php-5.4.8/ext/libxml/libxml.c:334
#5 0x000000000045509f in php_libxml_streams_IO_open_read_wrapper (URI=0x7ffff7fad2c8
"0\320\372\367\377\177", enc=XML_CHAR_ENCODING_NONE)
at /app/php-5.4.8/ext/libxml/libxml.c:345
#6 php_libxml_input_buffer_create_filename (URI=0x7ffff7fad2c8 "0\320\372\367\377\177",
enc=XML_CHAR_ENCODING_NONE)
at /app/php-5.4.8/ext/libxml/libxml.c:386
#7 0x00007ffff6dc7d8d in xmlNewInputFromFile () from /usr/lib/libxml2.so.2
#8 0x000000000045681b in _php_libxml_pre_ext_ent_loader (URL=0xea1990
"/app/libgda/share/libgda-4.0/dtd/libgda-array.dtd", ID=0x0,
context=0xe9e0b0) at /app/php-5.4.8/ext/libxml/libxml.c:694
#9 0x00007ffff6e8d59b in xmlSAX2ResolveEntity () from /usr/lib/libxml2.so.2
#10 0x00007ffff6de35a5 in xmlSAXParseDTD () from /usr/lib/libxml2.so.2
#11 0x00007ffff5687307 in gda_init () at gda-init.c:198
#12 0x00007ffff610c249 in midgard_init () at src/midgard.c:138
#13 0x00007ffff639cb61 in zm_startup_midgard2 (type=1, module_number=28) at
/app/midgard-php5-10.05.7/midgard.c:324
Steps from #11 to #8 clearly shows that php's hook is wrong in this case.
It doesn't happen with PHP 5.3, where global hook is not set.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64017&edit=1