[New-bugs-announce] [issue20766] reference leaks in pdb

Xavier de Gaye report at bugs.python.org
Tue Feb 25 12:02:34 CET 2014


New submission from Xavier de Gaye:

After the pdb 'continue' command, the signal module owns a reference to Pdb.sigint_handler. On the next instantiation of pdb, the signal module owns a reference to a new sigint_handler method that owns a reference to the previous sigint_handler. As a consequence, the first pdb instance is never freed (as well as the frames that are referenced by this pdb instance). The following test demonstrates the problem that is fixed by the attached patch.

Run the following script:

# START of refleak.py
import sys, gc, pdb

i = 1
while i:
    pdb.set_trace()
    x = 1
    gc.collect(); print(sys.gettotalrefcount())

# END of refleak.py


With the following pdb commands:

$ python refleak.py
> /tmp/test/refleak.py(6)<module>()
-> x = 1
(Pdb) continue
95898
> /home/xavier/tmp/test/refleak.py(5)<module>()
-> pdb.set_trace()
(Pdb) continue
95983
> /tmp/test/refleak.py(6)<module>()
-> x = 1
(Pdb) continue
96068
> /tmp/test/refleak.py(5)<module>()
-> pdb.set_trace()
(Pdb) i = 0
(Pdb) continue
96153

----------
components: Library (Lib)
files: refleak.patch
keywords: patch
messages: 212171
nosy: georg.brandl, xdegaye
priority: normal
severity: normal
status: open
title: reference leaks in pdb
type: behavior
versions: Python 3.4
Added file: http://bugs.python.org/file34220/refleak.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20766>
_______________________________________


More information about the New-bugs-announce mailing list