# Segfault when using ext/xml

- Thread: https://externals.io/message/2051
- Original archive: https://news-web.php.net/php.internals/2051
- Started by Per Lundberg on 2003-05-28T08:17:27+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #2051 — Per Lundberg — 2003-05-28T08:17:27+00:00

URL: https://externals.io/message/2051#2051

I get the following segfault when using the XML parser (ext/xml) using
the latest PHP5 from CVS:

Program received signal SIGSEGV, Segmentation fault.
0x0812e914 in _efree (ptr=0x5a5a5a5a, __zend_filename=0x8178fa0
"/usr/local/src/php-cvs/php5/ext/xml/xml.c", __zend_lineno=183,
__zend_orig_filename=0x0,
    __zend_orig_lineno=0) at
/usr/local/src/php-cvs/php5/Zend/zend_alloc.c:253
253             CALCULATE_REAL_SIZE_AND_CACHE_INDEX(p->size);
(gdb) backtrace
#0  0x0812e914 in _efree (ptr=0x5a5a5a5a, __zend_filename=0x8178fa0
"/usr/local/src/php-cvs/php5/ext/xml/xml.c", __zend_lineno=183,
__zend_orig_filename=0x0,
    __zend_orig_lineno=0) at
/usr/local/src/php-cvs/php5/Zend/zend_alloc.c:253
#1  0x080fcc10 in php_xml_free_wrapper (ptr=0x5a5a5a5a) at
/usr/local/src/php-cvs/php5/ext/xml/xml.c:183
#2  0x400b7303 in xmlCharEncCloseFunc () from /usr/lib/libxml2.so.2
#3  0x400d9b75 in xmlFreeParserInputBuffer () from /usr/lib/libxml2.so.2
#4  0x400bad9d in xmlFreeInputStream () from /usr/lib/libxml2.so.2
#5  0x400bb6fd in xmlFreeParserCtxt () from /usr/lib/libxml2.so.2
#6  0x08101036 in XML_ParserFree (parser=0x820da14) at
/usr/local/src/php-cvs/php5/ext/xml/compat.c:574
#7  0x080fd10e in xml_parser_dtor (rsrc=0x8403554) at
/usr/local/src/php-cvs/php5/ext/xml/xml.c:325
#8  0x0814a84f in list_entry_destructor (ptr=0x8403554) at
/usr/local/src/php-cvs/php5/Zend/zend_list.c:178
#9  0x08148d07 in zend_hash_apply_deleter (ht=0x81ad3a0, p=0x84034fc) at
/usr/local/src/php-cvs/php5/Zend/zend_hash.c:565
#10 0x08148f2c in zend_hash_graceful_reverse_destroy (ht=0x81ad3a0) at
/usr/local/src/php-cvs/php5/Zend/zend_hash.c:631
#11 0x0814a98f in zend_destroy_rsrc_list (ht=0x81ad3a0) at
/usr/local/src/php-cvs/php5/Zend/zend_list.c:234
#12 0x081385ef in shutdown_executor () at
/usr/local/src/php-cvs/php5/Zend/zend_execute_API.c:265
#13 0x08142a43 in zend_deactivate () at
/usr/local/src/php-cvs/php5/Zend/zend.c:781
#14 0x0810ae53 in php_request_shutdown (dummy=0x0) at
/usr/local/src/php-cvs/php5/main/main.c:1174
#15 0x081616ac in main (argc=3, argv=0xbffffac4) at
/usr/local/src/php-cvs/php5/sapi/cli/php_cli.c:1013
(gdb) print p->size
Cannot access memory at address 0x5a5a5a36

My libxml2 is version 2.5.6-2 (Debian precompiled package).

I have included a little script that will trigger the error.  It only
seems to occur when the start and end tag handlers are in a class -- so
perhaps OO support in PHP should be dropped altogether.  :-)

Anyone has any ideas?
--
Best regards,

Per Lundberg / Capio ApS
Phone: +46-18-4186040
Fax: +46-18-4186049
Web: http://www.nobolt.com

---

## #2057 — Per Lundberg — 2003-05-28T13:15:32+00:00

URL: https://externals.io/message/2051#2057

> cannot find the OO PHP script. Did you attach it?

Sorry.  I'm obviously doing too many things at one time.  Here it is,
attached to this email.

--
Best regards,

Per Lundberg / Capio ApS
Phone: +46-18-4186040
Fax: +46-18-4186049
Web: http://www.nobolt.com

---

## #2074 — Adam Dickmeiss — 2003-05-28T23:14:49+00:00

URL: https://externals.io/message/2051#2074 · In reply to: #2057

> 
> > […]
> 
> Sorry.  I'm obviously doing too many things at one time.  Here it is,
> attached to this email.

I see the almost same error and that is using and old version of libxml2.
In fact the error occurs even if ext/xml is configured to
use expat ('--with-libexpat-dir=/usr').

So, probably not an error in compat.c. Maybe zend or xml.c.

I recommend you enter a bug report.

-- Adam

> --
> Best regards,
> 
> Per Lundberg / Capio ApS
> Phone: +46-18-4186040
> Fax: +46-18-4186049
> Web: http://www.nobolt.com





-- 
Adam Dickmeiss  mailto:adam@indexdata.dk  http://www.indexdata.dk
Index Data      T: +45 33410100           Mob.: 212 212 66
