[issue35053] Enhance tracemalloc to trace properly free lists

STINNER Victor report at bugs.python.org
Wed Oct 24 08:09:09 EDT 2018


STINNER Victor <vstinner at redhat.com> added the comment:

Python 3.8 uses many free lists:
https://pythondev.readthedocs.io/cpython_impl_optim.html#free-lists

Attached dict_wrong_traceback.py shows the bug on the dictionary of an object:

$ ./python ~/dict_wrong_traceback.py 
  File "/home/vstinner/dict_wrong_traceback.py", line 13
    p = Point() # first object (dead!)
  File "/home/vstinner/dict_wrong_traceback.py", line 8
    self.x = 1

tracemalloc shows the traceback of the first object... which has been destroyed!

With the fix:

$ ./python ~/dict_wrong_traceback.py 
  File "/home/vstinner/dict_wrong_traceback.py", line 16
    p = Point() # second object (alive)
  File "/home/vstinner/dict_wrong_traceback.py", line 8
    self.x = 1

It's much better: it doesn't show dead objects anymore :-)

----------
Added file: https://bugs.python.org/file47889/dict_wrong_traceback.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35053>
_______________________________________


More information about the Python-bugs-list mailing list