New submission from James William Pye <x...@jwp.name>:

I found this bug by misplacing a line of a code. Yes, I was doing
naughty things, but in the case of the class that led to the discovery,
it was inadvertent. :P


class something_else(object):
 pass

class foo(object):
 def __del__(self):
  self.__class__ = something_else

for _ in range(1000):
 foo()

That results in a fatal python error due to a negative reference
count(on the foo class object) in 3.0.

3.0.1 (release30-maint:69593M, Feb 13 2009, 14:48:10) -> kaboom
j...@torch[]:org/pgfoundry/python 134% /src/build/py30/bin/python3.0
./kaboom.py
Fatal Python error: Objects/descrobject.c:10 object at 0x5221b8 has
negative ref count -1
zsh: abort      /src/build/py30/bin/python3.0 ./kaboom.py


2.6 (r26:66714, Dec 21 2008, 21:17:32) -> kaboom
j...@torch[]:org/pgfoundry/python 0% /sw/bin/python2.6 ./kaboom.py      
        
Fatal Python error: GC object already tracked
zsh: abort      /sw/bin/python2.6 ./kaboom.py


2.5.2 (r252:60911, Jun 15 2008, 18:55:39) -> no kaboom (no asserts? eh..)
...

2.5.1 (r251:54863, Apr 15 2008, 22:57:26) -> kaboom (/usr/bin/python2.5)
j...@torch[]:org/pgfoundry/python 0% /usr/bin/python2.5 ./kaboom.py
Assertion failed: (PyType_Check(base)), function _PyType_Lookup, file
Objects/typeobject.c, line 2035.
zsh: abort      /usr/bin/python2.5 ./kaboom.py

----------
components: Interpreter Core
files: kaboom.py
messages: 82272
nosy: jwp
severity: normal
status: open
title: setting __class__ in __del__ is bad. mmkay. negative ref count! kaboom!
type: crash
versions: Python 2.5, Python 2.6, Python 3.0
Added file: http://bugs.python.org/file13110/kaboom.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue5283>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to