Issue1586

classification
Title: weakref reference count leak when kwargs are used
Type: behaviour Severity: normal
Components: Core Versions: 2.5.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: jek, pjenvey, zyasoft
Priority: Keywords:

Created on 2010-03-29.00:01:43 by jek, last changed 2010-04-26.14:29:08 by zyasoft.

Files
File name Uploaded Description Edit Remove
weakly.py jek, 2010-03-29.00:01:43
Messages
msg5605 (view) Author: jason kirtland (jek) Date: 2010-03-29.00:01:43
It seems like some styles of function invocation might leak a strong reference to the function arguments.  Given a 

  def make_ref(obj, kwarg=True):
      return weakref.ref(obj, callback)

Calling make_ref(someobj) returns a weakref that functions as expected, but make_ref(someobj, kwarg=True) returns a weakref that seemingly can't ever go stale.  Test case attached.
msg5606 (view) Author: Philip Jenvey (pjenvey) Date: 2010-03-29.02:53:26
This is the fault of the compiler. Function calls w/ keywords create a PyObject[] positional+keyword args array and stores it in a local variable (of the JVM stack). That's supposed to be for temporary storage but the compiler doesn't explicitly null the local variable after the call is made, so the reference lingers until the Java method finishes

If you need to workaround this problem before we fix it, these reference should be freed when the current Python function returns
msg5749 (view) Author: Jim Baker (zyasoft) Date: 2010-04-26.14:29:08
In similar usage in the compiler to visitCall, we explicitly null out using the CodeCompiler#freeArray (such as visitList, visitDict, etc).

Fixed by r7047
History
Date User Action Args
2010-04-26 14:29:08zyasoftsetstatus: open -> closed
resolution: fixed
messages: + msg5749
2010-04-26 01:18:37zyasoftsetassignee: zyasoft
nosy: + zyasoft
2010-03-29 02:53:26pjenveysetnosy: + pjenvey
messages: + msg5606
2010-03-29 00:01:43jekcreate