python / cpython

The Python programming language
https://www.python.org/
Other
59.71k stars 28.94k forks source link

Plug sys.exc_info() leaks #35382

Closed tim-one closed 22 years ago

tim-one commented 22 years ago
BPO 473753
Nosy @tim-one

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields: ```python assignee = None closed_at = created_at = labels = ['interpreter-core'] title = 'Plug sys.exc_info() leaks' updated_at = user = 'https://github.com/tim-one' ``` bugs.python.org fields: ```python activity = actor = 'jhylton' assignee = 'jhylton' closed = True closed_date = None closer = None components = ['Interpreter Core'] creation = creator = 'tim.peters' dependencies = [] files = [] hgrepos = [] issue_num = 473753 keywords = [] message_count = 2.0 messages = ['7121', '7122'] nosy_count = 2.0 nosy_names = ['tim.peters', 'jhylton'] pr_nums = [] priority = 'normal' resolution = 'fixed' stage = None status = 'closed' superseder = None type = None url = 'https://bugs.python.org/issue473753' versions = [] ```

tim-one commented 22 years ago

As the Library manual has warned for years, this kind of program leaks bigtime:

import sys
def f():
.    try:
.        1 / 0
.    except ZeroDivisionError:
.        err = sys.exc_info()

while 1:
.    f()

because err[-1] is a traceback object, from which f's frame can be reached, from which we can get back to 'err'.

2.2 added frames to gc (thanks to NeilS), but this example still leaks. That's at best an embarrassing trap, and it just popped up again in Zope's testing framework. Best guess is that a cure amounts to adding traceback objects to gc too, although I haven't tried that so am not sure.

03bde425-37ce-4291-88bd-d6cecc46a30e commented 22 years ago

Logged In: YES user_id=31392

Fixed in rev 2.34 of traceback.c.