ID: 34232 Updated by: [EMAIL PROTECTED] Reported By: anders at kaseorg dot com -Status: Feedback +Status: Assigned Bug Type: Reproducible crash Operating System: Linux (Fedora Core 4) PHP Version: 5.0.4 -Assigned To: +Assigned To: rrichards New Comment:
Not yet sure if this will require changes to DOM and SimpleXML or libxml2 specific bug. Assigning to self for now. Current work around: Don't add meta element as its going to be destroyed and a new one added anyways when serializing. Previous Comments: ------------------------------------------------------------------------ [2005-08-24 11:34:34] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip ------------------------------------------------------------------------ [2005-08-24 10:55:24] anders at kaseorg dot com Description: ------------ Running PHP (5.0.4-10.3 on Fedora Core 4) on this code crashes with a "double free" error after producing correct output. If you comment the last appendChild line, it segfaults instead. Reproduce code: --------------- <?php $imp = new DOMImplementation(); $doc = $imp->createDocument( 'http://www.w3.org/1999/xhtml', 'html', $imp->createDocumentType('html', '-//W3C//DTD XHTML 1.0 Strict//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd') ); $html = $doc->documentElement; $head = $html->appendChild($doc->createElement('head')); $meta = $head->appendChild($doc->createElement('meta')); $meta->setAttribute('http-equiv', 'Content-Type'); $meta->setAttribute('content', 'application/xhtml+xml; charset=utf-8'); $head->appendChild($doc->createElement('title')); echo $doc->saveXML(); ?> Expected result: ---------------- <?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title></title></head></html> Actual result: -------------- <?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title></title></head></html> *** glibc detected *** php: double free or corruption (!prev): 0x0985dcf0 *** ======= Backtrace: ========= /lib/libc.so.6[0x984124] /lib/libc.so.6(__libc_free+0x77)[0x98465f] /usr/lib/libxml2.so.2(xmlFreeNode+0x1ce)[0x7535b66] php[0x80728be] php[0x80733cb] php[0x807339f] php(php_libxml_node_free_resource+0x3f)[0x8073423] php(php_libxml_node_decrement_resource+0x41)[0x807349b] /usr/lib/php/modules/dom.so(dom_objects_free_storage+0x54)[0xc14576] php(zend_objects_store_del_ref+0x72)[0x8187e48] php(_zval_ptr_dtor+0x36)[0x8168e3c] php[0x8179ffc] php(zend_hash_graceful_reverse_destroy+0x18)[0x817a116] php(shutdown_executor+0x7c)[0x8169a60] php(zend_deactivate+0x93)[0x81740de] php(php_request_shutdown+0x180)[0x813e197] php(main+0x174)[0x81a7895] /lib/libc.so.6(__libc_start_main+0xdf)[0x935d5f] php[0x80727b1] ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34232&edit=1