[XML-SIG] Wierd bug in DOM cloneNode (or copy.deepcopy)
Jeff.Johnson@stn.siemens.com
Jeff.Johnson@stn.siemens.com
Tue, 27 Oct 1998 14:21:50 -0500
--0__=yExnkLfCGsa1EvhnwXSAAuTTNFW1JdjQ75rjhoLcpf6FiQ8gvGCLsUzV
Content-type: text/plain; charset=us-ascii
Content-Disposition: inline
I have been trying to figure out what is crashing the Python interpreter on
Windows NT when I ran across a strange bug. My python program runs fine on
Win 98 but will crash on NT 4.0. It may take a few hours of running, but
eventually it crashes. I was hoping that if I could create a small test
file to reproduce the problem, I could get Guido to look into it. So... I
took my DOM test file and put in an infinite loop to see if it would crash
on NT. When I did, I noticed that __del__() is called more than __init__()
on xml.dom.core._nodeData when cloneNode() is used. I don't know what kind
of wierd voodoo happens in the copy.deepcopy() function but it looks like
it messes up the reference counts somehow.
That leads to a question about Python, how stable is the memory management?
Should I be surprised that it runs forever on Win98 but not on WinNT? Does
copy.deepcopy do things it should not?
Good news! While I was writing this, my test file did crash the interpreter
on NT. I'll comment out the cloneNode line and try again. Then I'm going
to load NT service pack 4 and try again. The exception was in malloc(). I
think I might have been out of memory. That's strange, if __del__ gets
called too many times, I would think the exception would be in free().
Anyone feel like figuring this one out?
(See attached file: test.py)
--0__=yExnkLfCGsa1EvhnwXSAAuTTNFW1JdjQ75rjhoLcpf6FiQ8gvGCLsUzV
Content-type: application/octet-stream;
name="test.py"
Content-Disposition: attachment; filename="test.py"
Content-transfer-encoding: base64
IiIiVGhpcyB0ZXN0cyB0aGUgbmV3IFhNTCBET00gcGFja2FnZSBmb3IgY2lyY3VsYXIgcmVmZXJl
bmNlIG1lbW9yeSBsZWFrcy4NClRvIHVzZSBpdCwgY29kZSBtdXN0IGJlIGFkZGVkIHRvIGNvcmUu
Tm9kZSBhbmQgY29yZS5fbm9kZURhdGEgdG8gaW5jcmVtZW50DQpOb2RlX2NvdW50ZXIgaW4gX19p
bml0X18gYW5kIGRlY3JlbWVudCBpdCBpbiBfX2RlbF9fL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