Hey Robin (and everyone else),
I've once again wandered into a Python garbage collection issue that
fairly reliably kills a wxPython application.
main thread:
repeated STC style changes via STCStyleEditor,
which uses wxFileConfig
second thread:
heavy C-level Python object allocation via compiler.parse()
I've hacked together a demo which includes everything necessary to
demonstrate this.
It breaks ansi wxPython 2.6.1.0 and 2.6.2.1 on Python 2.3.3 and Python
2.4.2 on Windows 2000. I've not tried unicode wxPython, but I wouldn't
imagine it would fare any better.
Can anyone verify if this does/does not break on their platform? You
may need to adjust the value of FC on the second line of smackgui2.py if
your platform is significantly slower or faster than a 2.8 ghz P4 (it's
the delay between style changes).
Behavior I have observed after the button has been pushed:
1. Fatal Python error: GC object already tracked
2. Everything works fine, but closing the program never returns you to
the command prompt.
3. ''"The instruction at "..." referenced memory at "...". The memory
could not be "read".'' The first address is obviously an instruction
address and varies within the binary image, the second address very much
likes to be 0xFFFFFFXX or 0x000000XX for some 'XX', and tends to vary
via quantum entanglement with the cat hair in my keyboard, but it has
been in the image, stack, and heap.
4. The application uses as much processor as it can, and becomes
non-responsive.
5. An unbelieveable traceback [1] whereby the two threads seemed to have
exchanged values (Mainthread got the result of 'len(nodelist') as its
input for len(val), and Thread-1 got 'val' as an argument to range).
6. On occasion, it works for a short period. I can move the window,
scroll, etc., and it doesn't die...for about 5 seconds.
- Josiah
[1] - (it's not the length, look at the exceptions themselves!)
Traceback (most recent call last):
File "C:\Python23\lib\site-packages\wx-2.6-msw-ansi\wx\_misc.py", line 1137, in Notify
self.notify()
File "C:\Python23\lib\site-packages\wx-2.6-msw-ansi\wx\_core.py", line 13368, in Notify
self.result = self.callable(*self.args, **self.kwargs)
File "D:\MYDOCS\Projects\python\smackgui2.py", line 60, in Style
STCStyleEditor.initSTC(self.stc, config, 'python')
File "D:\MYDOCS\Projects\python\STCStyleEditor.py", line 1307, in initSTC
(cfg, commonDefs, styleIdNames, styles, predefStyleGroupNames,
File "D:\MYDOCS\Projects\python\STCStyleEditor.py", line 1231, in initFromConfig
if val != groupPrefix and len(val) >= 5 and val[:5] == 'style':
TypeError: len() of unsized object
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Python23\lib\threading.py", line 436, in __bootstrap
self.run()
File "C:\Python23\lib\threading.py", line 416, in run
self.__target(*self.__args, **self.__kwargs)
File "D:\MYDOCS\Projects\python\smackgui2.py", line 30, in compile
x = compiler.parse(gs)
File "C:\python23\lib\compiler\transformer.py", line 50, in parse
return Transformer().parsesuite(buf)
File "C:\python23\lib\compiler\transformer.py", line 120, in parsesuite
return self.transform(parser.suite(text))
File "C:\python23\lib\compiler\transformer.py", line 113, in transform
return self.compile_node(tree)
File "C:\python23\lib\compiler\transformer.py", line 149, in compile_node
return self.file_input(node[1:])
File "C:\python23\lib\compiler\transformer.py", line 180, in file_input
self.com_append_stmt(stmts, node)
File "C:\python23\lib\compiler\transformer.py", line 1019, in com_append_stmt
result = self.com_node(node)
File "C:\python23\lib\compiler\transformer.py", line 762, in com_node
return self._dispatch[node[0]](node[1:])
File "C:\python23\lib\compiler\transformer.py", line 252, in stmt
return self.com_stmt(nodelist[0])
File "C:\python23\lib\compiler\transformer.py", line 1012, in com_stmt
result = self.lookup_node(node)(node[1:])
File "C:\python23\lib\compiler\transformer.py", line 252, in stmt
return self.com_stmt(nodelist[0])
File "C:\python23\lib\compiler\transformer.py", line 1012, in com_stmt
result = self.lookup_node(node)(node[1:])
File "C:\python23\lib\compiler\transformer.py", line 204, in funcdef
code = self.com_node(nodelist[4])
File "C:\python23\lib\compiler\transformer.py", line 762, in com_node
return self._dispatch[node[0]](node[1:])
File "C:\python23\lib\compiler\transformer.py", line 519, in suite
self.com_append_stmt(stmts, node)
File "C:\python23\lib\compiler\transformer.py", line 1019, in com_append_stmt
result = self.com_node(node)
File "C:\python23\lib\compiler\transformer.py", line 762, in com_node
return self._dispatch[node[0]](node[1:])
File "C:\python23\lib\compiler\transformer.py", line 252, in stmt
return self.com_stmt(nodelist[0])
File "C:\python23\lib\compiler\transformer.py", line 1012, in com_stmt
result = self.lookup_node(node)(node[1:])
File "C:\python23\lib\compiler\transformer.py", line 252, in stmt
return self.com_stmt(nodelist[0])
File "C:\python23\lib\compiler\transformer.py", line 1012, in com_stmt
result = self.lookup_node(node)(node[1:])
File "C:\python23\lib\compiler\transformer.py", line 204, in funcdef
code = self.com_node(nodelist[4])
File "C:\python23\lib\compiler\transformer.py", line 762, in com_node
return self._dispatch[node[0]](node[1:])
File "C:\python23\lib\compiler\transformer.py", line 519, in suite
self.com_append_stmt(stmts, node)
File "C:\python23\lib\compiler\transformer.py", line 1019, in com_append_stmt
result = self.com_node(node)
File "C:\python23\lib\compiler\transformer.py", line 762, in com_node
return self._dispatch[node[0]](node[1:])
File "C:\python23\lib\compiler\transformer.py", line 252, in stmt
return self.com_stmt(nodelist[0])
File "C:\python23\lib\compiler\transformer.py", line 1012, in com_stmt
result = self.lookup_node(node)(node[1:])
File "C:\python23\lib\compiler\transformer.py", line 252, in stmt
return self.com_stmt(nodelist[0])
File "C:\python23\lib\compiler\transformer.py", line 1012, in com_stmt
result = self.lookup_node(node)(node[1:])
File "C:\python23\lib\compiler\transformer.py", line 476, in while_stmt
bodyNode = self.com_node(nodelist[3])
File "C:\python23\lib\compiler\transformer.py", line 762, in com_node
return self._dispatch[node[0]](node[1:])
File "C:\python23\lib\compiler\transformer.py", line 519, in suite
self.com_append_stmt(stmts, node)
File "C:\python23\lib\compiler\transformer.py", line 1019, in com_append_stmt
result = self.com_node(node)
File "C:\python23\lib\compiler\transformer.py", line 762, in com_node
return self._dispatch[node[0]](node[1:])
File "C:\python23\lib\compiler\transformer.py", line 252, in stmt
return self.com_stmt(nodelist[0])
File "C:\python23\lib\compiler\transformer.py", line 1012, in com_stmt
result = self.lookup_node(node)(node[1:])
File "C:\python23\lib\compiler\transformer.py", line 262, in simple_stmt
self.com_append_stmt(stmts, nodelist[i])
File "C:\python23\lib\compiler\transformer.py", line 1019, in com_append_stmt
result = self.com_node(node)
File "C:\python23\lib\compiler\transformer.py", line 762, in com_node
return self._dispatch[node[0]](node[1:])
File "C:\python23\lib\compiler\transformer.py", line 252, in stmt
return self.com_stmt(nodelist[0])
File "C:\python23\lib\compiler\transformer.py", line 1012, in com_stmt
result = self.lookup_node(node)(node[1:])
File "C:\python23\lib\compiler\transformer.py", line 300, in expr_stmt
exprNode = self.lookup_node(en)(en[1:])
File "C:\python23\lib\compiler\transformer.py", line 531, in testlist
return self.com_binary(Tuple, nodelist)
File "C:\python23\lib\compiler\transformer.py", line 1004, in com_binary
return self.lookup_node(n)(n[1:])
File "C:\python23\lib\compiler\transformer.py", line 541, in test
return self.com_binary(Or, nodelist)
File "C:\python23\lib\compiler\transformer.py", line 1004, in com_binary
return self.lookup_node(n)(n[1:])
File "C:\python23\lib\compiler\transformer.py", line 545, in and_test
return self.com_binary(And, nodelist)
File "C:\python23\lib\compiler\transformer.py", line 1004, in com_binary
return self.lookup_node(n)(n[1:])
File "C:\python23\lib\compiler\transformer.py", line 549, in not_test
result = self.com_node(nodelist[-1])
File "C:\python23\lib\compiler\transformer.py", line 762, in com_node
return self._dispatch[node[0]](node[1:])
File "C:\python23\lib\compiler\transformer.py", line 558, in comparison
node = self.com_node(nodelist[0])
File "C:\python23\lib\compiler\transformer.py", line 762, in com_node
return self._dispatch[node[0]](node[1:])
File "C:\python23\lib\compiler\transformer.py", line 593, in expr
return self.com_binary(Bitor, nodelist)
File "C:\python23\lib\compiler\transformer.py", line 1004, in com_binary
return self.lookup_node(n)(n[1:])
File "C:\python23\lib\compiler\transformer.py", line 597, in xor_expr
return self.com_binary(Bitxor, nodelist)
File "C:\python23\lib\compiler\transformer.py", line 1004, in com_binary
return self.lookup_node(n)(n[1:])
File "C:\python23\lib\compiler\transformer.py", line 601, in and_expr
return self.com_binary(Bitand, nodelist)
File "C:\python23\lib\compiler\transformer.py", line 1004, in com_binary
return self.lookup_node(n)(n[1:])
File "C:\python23\lib\compiler\transformer.py", line 606, in shift_expr
for i in range(2, len(nodelist), 2):
TypeError: range() integer end argument expected, got str.
kill_gui.zip (18 KB)