==> test_level1_core_attrcreatedocumentfragment.....................FAIL Failure detected: consult log file make: *** [/usr/share/netsurf-buildsystem/makefiles/Makefile.subdir:87: test_test/] Error 1 * ERROR: net-libs/libdom-0.4.2::gentoo failed (test phase): * emake failed ------------------------------------------------------------------- This is an unstable amd64 chroot image at a tinderbox (==build bot) name: 23.0_systemd_test-20241217-170002 UNMASKED: <sys-devel/gcc-15.0.9999:15 The attached etc.portage.tar.xz has all details. ------------------------------------------------------------------- gcc-config -l: [1] x86_64-pc-linux-gnu-15 * clang version 19.1.6 llvm-config: 19.1.6 Python 3.12.8 go version go1.23.4 linux/amd64 Available Ruby profiles: [1] ruby32 (with Rubygems) * Available Rust versions: [1] rust-bin-1.81.0 [2] rust-bin-1.83.0 * The following VMs are available for generation-2: 1) Eclipse Temurin JDK 11.0.25_p9 [openjdk-bin-11] *) Eclipse Temurin JDK 21.0.5_p11 [openjdk-bin-21] 3) Eclipse Temurin JDK 8.432_p06 [openjdk-bin-8] Available Java Virtual Machines: [1] openjdk-bin-8 [2] openjdk-bin-11 [3] openjdk-bin-21 system-vm HEAD of ::gentoo commit 12b5e27b9c730a5f8f83344eb799cd4c0274ed58 Author: Repository mirror & CI <repomirrorci@gentoo.org> Date: Tue Dec 24 08:18:39 2024 +0000 2024-12-24 08:18:39 UTC emerge -qpvO =net-libs/libdom-0.4.2 [ebuild N ] net-libs/libdom-0.4.2 USE="test xml -expat"
Created attachment 915089 [details] emerge-info.txt
Created attachment 915090 [details] emerge-history.txt.xz
Created attachment 915091 [details] environment
Created attachment 915092 [details] etc.clang.tar.xz
Created attachment 915093 [details] etc.portage.tar.xz
Created attachment 915094 [details] net-libs:libdom-0.4.2:20241224-091312.log.xz
Created attachment 915095 [details] qlist-info.txt.xz
Created attachment 915096 [details] temp.tar.xz
``` /var/tmp/portage/net-libs/libdom-0.4.2/work/libdom-0.4.2/test/ test_ Test: level1_core_attrcreatedocumentfragment ==> test_level1_core_attrcreatedocumentfragment.....................FAIL Failure detected: consult log file make: *** [/usr/share/netsurf-buildsystem/makefiles/Makefile.subdir:87: test_test/] Error 1 * ERROR: net-libs/libdom-0.4.2::gentoo failed (test phase): ``` Let's see.
build-x86_64-pc-linux-gnu-x86_64-pc-linux-gnu-release-lib-shared/testlog: ``` Running build-x86_64-pc-linux-gnu-x86_64-pc-linux-gnu-release-lib-shared/test_level1_core_attrcreatedocumentfragment FAIL: Exit status 11 ``` well.
``` /var/tmp/portage/net-libs/libdom-0.4.2/work/libdom-0.4.2 $ LD_LIBRARY_PATH="build-x86_64-pc-linux-gnu-x86_64-pc-linux-gnu-release-lib-shared:" gdb --args build-x86_64-pc-linux-gnu-x86_64-pc-linux-gnu-release-lib-shared/test_level1_core_attrcreatedocumentfragment Program received signal SIGSEGV, Segmentation fault. xml_parser_add_element_node (parser=0x555555582ea0, parent=0x0, child=<optimized out>) at bindings/xml/libxml_xmlparser.c:896 896 err = dom_node_append_child(parent, (struct dom_node *) el, (gdb) bt #0 xml_parser_add_element_node (parser=0x555555582ea0, parent=0x0, child=<optimized out>) at bindings/xml/libxml_xmlparser.c:896 #1 xml_parser_add_node (parser=parser@entry=0x555555582ea0, parent=0x0, child=<optimized out>) at bindings/xml/libxml_xmlparser.c:632 #2 0x00007ffff7f8aa66 in xml_parser_start_element_ns (ctx=0x555555582ea0, localname=<optimized out>, prefix=<optimized out>, URI=<optimized out>, nb_namespaces=<optimized out>, namespaces=<optimized out>, nb_attributes=2, nb_defaulted=1, attributes=0x555555579b10) at bindings/xml/libxml_xmlparser.c:494 #3 0x00007ffff7d72f47 in xmlParseStartTag2 (ctxt=ctxt@entry=0x5555555777d0, pref=pref@entry=0x7fffffffd878, URI=URI@entry=0x7fffffffd870, nbNsPtr=nbNsPtr@entry=0x7fffffffd86c) at /usr/src/debug/dev-libs/libxml2-2.13.5/libxml2-2.13.5/parser.c:9551 #4 0x00007ffff7d739bf in xmlParseElementStart (ctxt=ctxt@entry=0x5555555777d0) at /usr/src/debug/dev-libs/libxml2-2.13.5/libxml2-2.13.5/parser.c:9947 #5 0x00007ffff7d7415e in xmlParseContentInternal (ctxt=0x5555555777d0) at /usr/src/debug/dev-libs/libxml2-2.13.5/libxml2-2.13.5/parser.c:9789 #6 0x00007ffff7d7b989 in xmlCtxtParseContent (ctxt=ctxt@entry=0x5555555777d0, input=input@entry=0x5555555845f0, hasTextDecl=0, buildTree=1) at /usr/src/debug/dev-libs/libxml2-2.13.5/libxml2-2.13.5/parser.c:12081 #7 0x00007ffff7d7c7e3 in xmlCtxtParseEntity (ctxt=0x5555555777d0, ent=0x5555555769d0) at /usr/src/debug/dev-libs/libxml2-2.13.5/libxml2-2.13.5/parser.c:12193 #8 0x00007ffff7d6fbd6 in xmlParseReference (ctxt=<optimized out>) at /usr/src/debug/dev-libs/libxml2-2.13.5/libxml2-2.13.5/parser.c:7438 #9 0x00007ffff7d75bf3 in xmlParseTryOrFinish.isra.0 (ctxt=ctxt@entry=0x5555555777d0, terminate=terminate@entry=0) at /usr/src/debug/dev-libs/libxml2-2.13.5/libxml2-2.13.5/parser.c:11339 #10 0x00007ffff7d78d9d in xmlParseChunk (ctxt=0x5555555777d0, chunk=<optimized out>, size=<optimized out>, terminate=0) at /usr/src/debug/dev-libs/libxml2-2.13.5/libxml2-2.13.5/parser.c:11636 #11 0x00007ffff7f854d2 in dom_xml_parser_parse_chunk (parser=parser@entry=0x555555582ea0, data=data@entry=0x7fffffffdb60 "</position>\n <salary>35,000</salary>\n <gender>Female</gender>\n <address domestic=\"Yes\" street=\"Yes\">&ent2; Dallas, &ent3;\n 98554</address>\n </employee>\n <employee>\n <employeeId>EMP0003</employeeId"..., len=len@entry=949) at bindings/xml/libxml_xmlparser.c:272 #12 0x0000555555556510 in load_xml (willBeModified=<optimized out>, file=<optimized out>) at test/testutils/load.c:70 #13 0x0000555555556c86 in main (argc=<optimized out>, argv=<optimized out>) at test/level1_core_attrcreatedocumentfragment.c:51 ```
It fails with GCC 14 too, so probably not my problem ;)
==3300613== Invalid read of size 8 ==3300613== at 0x4867AE4: dom_node_append_child (node.h:372) ==3300613== by 0x4867AE4: xml_parser_add_element_node (libxml_xmlparser.c:896) ==3300613== by 0x4867B7D: xml_parser_add_node (libxml_xmlparser.c:632) ==3300613== by 0x4867F26: xml_parser_start_element_ns (libxml_xmlparser.c:494) ==3300613== by 0x4A05F46: xmlParseStartTag2.constprop.0 (parser.c:9551) ==3300613== by 0x4A069BE: xmlParseElementStart (parser.c:9947) ==3300613== by 0x4A0715D: xmlParseContentInternal.lto_priv.0 (parser.c:9789) ==3300613== by 0x4A0E988: xmlCtxtParseContent (parser.c:12081) ==3300613== by 0x4A0F7E2: xmlCtxtParseEntity.lto_priv.0 (parser.c:12193) ==3300613== by 0x4A02BD5: xmlParseReference (parser.c:7438) ==3300613== by 0x4A08BF2: xmlParseTryOrFinish.isra.0 (parser.c:11339) ==3300613== by 0x4A0BD9C: xmlParseChunk.part.0 (parser.c:11636) ==3300613== by 0x48682C7: dom_xml_parser_parse_chunk (libxml_xmlparser.c:272) ==3300613== Address 0x0 is not stack'd, malloc'd or (recently) free'd ==3300613== ==3300613== ==3300613== Process terminating with default action of signal 11 (SIGSEGV): dumping core ==3300613== Access not within mapped region at address 0x0 ==3300613== at 0x4867AE4: dom_node_append_child (node.h:372) ==3300613== by 0x4867AE4: xml_parser_add_element_node (libxml_xmlparser.c:896) ==3300613== by 0x4867B7D: xml_parser_add_node (libxml_xmlparser.c:632) ==3300613== by 0x4867F26: xml_parser_start_element_ns (libxml_xmlparser.c:494) ==3300613== by 0x4A05F46: xmlParseStartTag2.constprop.0 (parser.c:9551) ==3300613== by 0x4A069BE: xmlParseElementStart (parser.c:9947) ==3300613== by 0x4A0715D: xmlParseContentInternal.lto_priv.0 (parser.c:9789) ==3300613== by 0x4A0E988: xmlCtxtParseContent (parser.c:12081) ==3300613== by 0x4A0F7E2: xmlCtxtParseEntity.lto_priv.0 (parser.c:12193) ==3300613== by 0x4A02BD5: xmlParseReference (parser.c:7438) ==3300613== by 0x4A08BF2: xmlParseTryOrFinish.isra.0 (parser.c:11339) ==3300613== by 0x4A0BD9C: xmlParseChunk.part.0 (parser.c:11636) ==3300613== by 0x48682C7: dom_xml_parser_parse_chunk (libxml_xmlparser.c:272)
(gdb) frame #3 0x00007ffff7f65f27 in xml_parser_start_element_ns (ctx=0x555555583ea0, localname=<optimized out>, prefix=<optimized out>, URI=<optimized out>, nb_namespaces=<optimized out>, namespaces=<optimized out>, nb_attributes=2, nb_defaulted=1, attributes=0x55555557ab10) at bindings/xml/libxml_xmlparser.c:494 494 parser->err = xml_parser_add_node(parser, (gdb) p parent->_private $7 = (void *) 0x0 Wonder if it's a libxml2 (or libxslt?) regression
It passes for me if I downgrade to libxml2-2.12.9.
I've no idea if _private is something that libdom should be poking around in or not, or what, so over to you mjo. If it looks like a libxml2 bug instead, let me know.
The _private field on the libxml node is a void* to "application data," i.e. a place to store whatever you want. libdom uses it to store a pointer to the associated libdom node (every libdom node has an associated libxml node, and vice versa). So a priori it's not surprising that we're meddling with it. This will probably require some printf debugging in libdom to see what changes when libxml is upgraded.
I think this may actually be a bug in libxml2. The failing test case is loading this document: https://git.netsurf-browser.org/libdom.git/tree/test/testcases/tests/level1/core/files/staff.xml The error happens while it is loading the third employee, Roger Jones, whose gender consists of an entity reference: <gender>&ent4;</gender> That entity is defined as, <!ENTITY ent4 "<entElement domestic='Yes'>Element data</entElement><?PItarget PIdata?>"> In libxml2-2.12.9, what happens is that the "entElement" node contained in the entity reference is added with Roger's <gender> element as its parent. This is well beyond my knowledge of the XML spec, but that sounds reasonable, and is what would happen if the text from the entity reference were simply inlined into the document. In libxml2-2.13.5, however, that "entElement" is added with a NULL parent. To find this out I just added a bunch of printf statements and ran the test case. Here's what adding Roger's <gender> node looks like when everything works: xml_parser_add_node parent=employee, child=gender xml_parser_add_element_node parent=employee, child=gender linking node gender while adding it xml_parser_link_nodes gender->gender xml_parser_start_element_ns with parent gender xml_parser_add_node parent=gender, child=entElement xml_parser_add_element_node parent=gender, child=entElement And here's what it looks like when it segfaults: xml_parser_add_node parent=employee, child=gender xml_parser_add_element_node parent=employee, child=gender linking node gender while adding it xml_parser_link_nodes gender->gender xml_parser_start_element_ns with parent #root xml_parser_add_node with parent=NULL, child=entElement xml_parser_add_element_node with parent=NULL, child=entElement Presumably attaching the <entElement> that arises from <gender>&ent4;</gender> to the document root is a bug?
Back to it being a libdom issue. Apparently libdom _is_ relying on libxml internals, but it's in the assignment xmlNodePtr parent = parser->xml_ctx->node; Apparently that was never reliable and only contains the parent element if you are lucky. And the way that entity parsing happens in 2.13.x changed such that we are not lucky any more.