Bugs item #1370197, was opened at 2005-11-30 08:41
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1370197&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: AST
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: Jim Jewett (jimjjewett)
>Assigned to: Neal Norwitz (nnorwitz)
Summary: memory leak - ast_error_finish

Initial Comment:
http://svn.python.org/view/python/trunk/Python/ast.c?
rev=41486&view=markup

function ast_error_finish

It first gets the errstr, for a possible early out.
If there is an error string, it is increfed, but it is 
not decrefed on the other early outs.  (lineno==-1 and 
failure to build a tmp.


"""
    Py_INCREF(errstr);
    lineno = PyInt_AsLong(PyTuple_GetItem(value, 1));
    if (lineno == -1)
return;
    Py_DECREF(value);

    loc = PyErr_ProgramText(filename, lineno);
    if (!loc) {
Py_INCREF(Py_None);
loc = Py_None;
    }
    tmp = Py_BuildValue("(ziOO)", filename, lineno, 
Py_None, loc);
    Py_DECREF(loc);
    if (!tmp)
return;
    value = Py_BuildValue("(OO)", errstr, tmp);
    Py_DECREF(errstr);
"""




----------------------------------------------------------------------

>Comment By: Neal Norwitz (nnorwitz)
Date: 2005-12-11 12:09

Message:
Logged In: YES 
user_id=33168

You are correct.  I thought I had tested, but test_grammar
failed with my removal.  I added the DECREFs.

Committed revision 41641.

Thanks for tracking this down.


----------------------------------------------------------------------

Comment By: Jim Jewett (jimjjewett)
Date: 2005-12-02 11:14

Message:
Logged In: YES 
user_id=764593

No, though it took me a *long* time to see why, because the 
&value pointer is reused.

As best I understand it, PyErr_Fetch may leave (the initial 
value of) value with the only reference to errstr.

There is a Py_DECREF(value) after successfully retrieving a 
line number, but before using errstr to build the (new value 
of) value for PyErr_Restore.


----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2005-12-01 21:22

Message:
Logged In: YES 
user_id=33168

ISTM that we don't need the INCREF or DECREF for errstr.  Do
you agree?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1370197&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to