I have found a bug in TclDOM 3.1 under RHEL WS 4 Update 3 and ActiveTcl
8.4.12.0 related to node duplication and memory allocation/deallocation.
The following script demonstrates the error:
package require dom
set fid [open $argv r]
set doc1 [dom::parse [read $fid]]
close $fid
dom::trim $doc1
puts [dom::serialize $doc1]
set root1 [dom::document cget $doc1 -documentElement]
set node [dom::selectNode $root1 child::analysis]
set doc2 [dom::create]
set root2 [dom::document createElement $doc2 maxmin]
dom::element setAttribute $root2 analyses 1
dom::element setAttribute $root2 version [dom::element getAttribute
$root1 version]
dom::node appendChild $root2 $node
puts [dom::serialize $doc2]
dom::destroy $doc1
dom::destroy $doc2
exit
Use the following as a data file:
<?xml version="1.0" encoding="utf-8"?>
<maxmin analyses="1" version="1.0">
<analysis number="1" items="8" variations="1" ID="NL">
<title>Interface Forces</title>
<subtitle>Nominal Landing Manifest Configuration</subtitle>
<label>STS-121 VLA-1 IV&V</label>
</analysis>
</maxmin>
And execute the example as follows:
$ tclsh8.4 test.tcl test.xml
<?xml version="1.0" encoding="utf-8"?>
<maxmin analyses="1" version="1.0"><analysis number="1" items="8"
variations="1" ID="NL"><title>Interface
Forces</title><subtitle>Nominal Landing Manifest
Configuration</subtitle><label>STS-121 VLA-1
IV&V</label></analysis></maxmin>
<?xml version="1.0" encoding="utf-8"?>
<maxmin analyses="1" version="1.0"><analysis number="1" items="8"
variations="1" ID="NL"><title>Interface
Forces</title><subtitle>Nominal Landing Manifest
Configuration</subtitle><label>STS-121 VLA-1
IV&V</label></analysis></maxmin>
*** glibc detected *** free(): invalid pointer: 0x080ca82c ***
Aborted
If you set the environment variable MALLOC_CHECK_=1, you will see that
many attempts are made to free invalid pointers. Experimentation has
isolated the error to appendChild command. As you can see the "new"
document is an exact copy of the original document as it should be. I
suspect that the when the node is removed from the original parent, the
node's document, parent, children, or sibling references are not being
updated properly.
Kevin
--
Kevin Partin
(281) 286-8959
mailto:Kev...@Ap...
|