Created attachment 658909 [details] Demonstration Tcl script Description of problem: tDOM includes its own block-allocator which is enabled by default, but only works correctly on 32-bit architectures. The tDOM-0.8.2/unix/CONFIG file says: # --enable-tdomalloc # Default: on # With this option on, a special memory allocator is used, which is # optimized for low memory allocation overhead. This allocator works # only on 32-bit plattforms. If you build for a 64-bit OS, you _must_ # disable this. The EPEL package does not disable it. Version-Release number of selected component (if applicable): 0.8.2-6 How reproducible: The attached Tcl script parses a small piece of XML into a DOM-tree, selects two nodes and deletes them. Because of the use of tDOM's block-allocator the nodes overlap in memory and the deletion of the first node corrupts the second one, leading to a seg-fault during the deletion of the second node. Steps to Reproduce: 1. Run the attached Tcl script. 2. 3. Actual results: Here is the output of the script: [jsowden.openbet:~/tmp/tdomtest] $ ./tdomtest.tcl <root> <child> <attr1>one</attr1> <attr2>two</attr2> <attr3>three</attr3> <attr4>four</attr4> <attr5>five</attr5> <attr6>six</attr6> <attr7>seven</attr7> <attr8>eight</attr8> </child> </root> AZL: 0: domNode0x10f8878 AZL: 1: domNode0x1104cac - domDoc0x10da0c0 AZL: 1: domNode0x1104ce4 - domDoc0x10da0c0 AZL: 2: domNode0x1104ce4 - AZL: 3 AZL: 0: domNode0x10f88c8 AZL: 1: domNode0x1104ce4 - Segmentation fault (core dumped) The two nodes to be deleted are domNode0x1104cac and domNode0x1104ce4. The names of the nodes correspond to their locations in memory. Given that sizeof (domNode) == 80 but 0x1104ce4 - 0x1104cac == 56, it is clear that they must overlap. Expected results: After this patch had been applied to the spec-file: --- SPECS/tdom.spec~ 2012-12-06 17:30:32.559448879 +0000 +++ SPECS/tdom.spec 2012-12-06 17:30:35.031448564 +0000 @@ -35,7 +35,11 @@ %build +%ifarch %ix86 %configure --enable-threads +%else +%configure --enable-threads --disable-tdomalloc +%endif make %{?_smp_mflags} %install and the package had been rebuilt and reinstalled, the following output from the script was observed: [jsowden.openbet:~/tmp/tdomtest] $ ./tdomtest.tcl <root> <child> <attr1>one</attr1> <attr2>two</attr2> <attr3>three</attr3> <attr4>four</attr4> <attr5>five</attr5> <attr6>six</attr6> <attr7>seven</attr7> <attr8>eight</attr8> </child> </root> AZL: 0: domNode0x1a67780 AZL: 1: domNode0x1a677e0 - domDoc0x1a820c0 AZL: 1: domNode0x1a8eca0 - domDoc0x1a820c0 AZL: 2: domNode0x1a8eca0 - domDoc0x1a820c0 AZL: 3 AZL: 0: domNode0x1a8ec40 AZL: 1: domNode0x1a8eca0 - domDoc0x1a820c0 AZL: 3 The two deleted nodes are no longer overlapping and the script runs to completion. Additional info: The particular code in tDOM which causes this crash is tDOM-0.8.2/generic/dom.c, ll. 2583ff.: TDomThreaded ( if (shared) { if (doc->deletedNodes) { doc->deletedNodes->nextDeleted = node; } else { doc->deletedNodes = node; } node->nodeFlags |= IS_DELETED; node->nextDeleted = NULL; } ) node->nextDeleted is near the end of the structure and overlaps the ownerDocument field of the following node. Therefore, when NULL is assigned to it, the ownerDocument field is also overwritten, leading to a subsequent null- pointer-dereference.
I've had another look at this problem and it turns out that the problem does not derive solely from the use of the tDOM block-allocator. tDOM uses a generic domNode structure and different structures (e.g., domTextNode) that it uses for specific types of leaf-node. All these types should have a common sequence of members at the start to allow tDOM to treat them all as domNode's where appropriate. The bug in the code above, however, lies in the fact that only the domNode structure has a nextDeleted element and so when a domTextNode is type-punned and manipulated as if it were a domNode, the NULL is assigned to memory beyond the end of the object. The reason that disabling the tDOM allocator appeared to fix the problem was that doing so reduced the chance that another object would immediately follow the deleted node in memory. I've reported the bug upstream. A patch to fix it is attached.
Created attachment 672141 [details] Patch to add nodesDeleted as common member for all node types
(In reply to comment #1) > I've reported the bug upstream. A patch to fix it is attached. https://github.com/tDOM/tdom/issues/14
This message is a reminder that EPEL 6 is nearing its end of life. Fedora will stop maintaining and issuing updates for EPEL 6 on 2020-11-30. It is our policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a 'version' of 'el6'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later EPEL version. Thank you for reporting this issue and we are sorry that we were not able to fix it before EPEL 6 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above.
This message is a reminder that EPEL 6 is nearing its end of life. Fedora will stop maintaining and issuing updates for EPEL 6 on 2020-11-30. It is policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a 'version' of 'el6'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later EPEL version. Thank you for reporting this issue and we are sorry that we were not able to fix it before EPEL 6 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version, you are encouraged to change the 'version' to a later version prior this bug is closed as described in the policy above.
EPEL el6 changed to end-of-life (EOL) status on 2020-11-30. EPEL el6 is no longer maintained, which means that it will not receive any further security or bug fix updates. As a result we are closing this bug. If you can reproduce this bug against a currently maintained version of EPEL please feel free to reopen this bug against that version. If you are unable to reopen this bug, please file a new report against the current release. If you experience problems, please add a comment to this bug. Thank you for reporting this bug and we are sorry it could not be fixed.