Attachment 'leak_frame.patch'

Download

   1 Index: src/engine/SCons/Defaults.py
   2 ===================================================================
   3 --- src/engine/SCons/Defaults.py	(revision 2988)
   4 +++ src/engine/SCons/Defaults.py	(working copy)
   5 @@ -414,7 +414,10 @@
   6          self.method = method
   7      def __call__(self, *args, **kw):
   8          try: 1/0
   9 -        except ZeroDivisionError: frame = sys.exc_info()[2].tb_frame
  10 +        except ZeroDivisionError: 
  11 +            # Warning: Don't start iterating with the current stack-frame to
  12 +            # prevent creating reference cycles (f_back is save).
  13 +            frame = sys.exc_info()[2].tb_frame.f_back
  14          variable = self.variable
  15          while frame:
  16              if frame.f_locals.has_key(variable):
  17 Index: src/engine/SCons/Script/SConscript.py
  18 ===================================================================
  19 --- src/engine/SCons/Script/SConscript.py	(revision 2988)
  20 +++ src/engine/SCons/Script/SConscript.py	(working copy)
  21 @@ -81,7 +81,10 @@
  22      """Return the locals and globals for the function that called
  23      into this module in the current call stack."""
  24      try: 1/0
  25 -    except ZeroDivisionError: frame = sys.exc_info()[2].tb_frame
  26 +    except ZeroDivisionError: 
  27 +        # Warning: Don't start iterating with the current stack-frame to
  28 +        # prevent creating reference cycles (f_back is save).
  29 +        frame = sys.exc_info()[2].tb_frame.f_back
  30  
  31      # Find the first frame that *isn't* from this file.  This means
  32      # that we expect all of the SCons frames that implement an Export()
  33 Index: src/engine/SCons/SConf.py
  34 ===================================================================
  35 --- src/engine/SCons/SConf.py	(revision 2988)
  36 +++ src/engine/SCons/SConf.py	(working copy)
  37 @@ -235,7 +235,9 @@
  38              raise
  39          elif issubclass(exc_type, SCons.Errors.BuildError):
  40              # we ignore Build Errors (occurs, when a test doesn't pass)
  41 -            pass
  42 +            # Clear the exception to prevent the contained traceback to build a
  43 +            # reference cycle.
  44 +            self.exc_clear()
  45          else:
  46              self.display('Caught exception while building "%s":\n' %
  47                           self.targets[0])

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.

You are not allowed to attach a file to this page.