<feed xmlns='http://www.w3.org/2005/Atom'>
<title>python.git/Modules/gcmodule.c, branch 2.2</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.</subtitle>
<id>http://dangofactory.net/cgit/cgit.cgi/Server/python.git/atom/Modules/gcmodule.c?h=2.2</id>
<link rel='self' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/atom/Modules/gcmodule.c?h=2.2'/>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/'/>
<updated>2003-04-08T20:33:05Z</updated>
<entry>
<title>Fixed the gc-vs-__del__ bugs for new-style classes.  That's it for this one.</title>
<updated>2003-04-08T20:33:05Z</updated>
<author>
<name>Tim Peters</name>
<email>tim.peters@gmail.com</email>
</author>
<published>2003-04-08T20:33:05Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=8998a819375d8aa439e560472edcee9d9fa5475c'/>
<id>urn:sha1:8998a819375d8aa439e560472edcee9d9fa5475c</id>
<content type='text'>
</content>
</entry>
<entry>
<title>More backporting of gc-vs-__del__ fixes.  It should be fixed for instances</title>
<updated>2003-04-08T19:13:14Z</updated>
<author>
<name>Tim Peters</name>
<email>tim.peters@gmail.com</email>
</author>
<published>2003-04-08T19:13:14Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=539afe0d8412551503e75b20a1f010560aa5fbc1'/>
<id>urn:sha1:539afe0d8412551503e75b20a1f010560aa5fbc1</id>
<content type='text'>
of classic classes now.  Alas, new-style classes are still a problem, and
didn't need to be fixed in 2.3 (they were already immune in 2.3 due to the
new-in-2.3 tp_del slot).
</content>
</entry>
<entry>
<title>Fix memory corruption in garbage collection.</title>
<updated>2003-04-03T23:02:29Z</updated>
<author>
<name>Jeremy Hylton</name>
<email>jeremy@alum.mit.edu</email>
</author>
<published>2003-04-03T23:02:29Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=f95350079cb0e93c57709b1166f969505dfd33a1'/>
<id>urn:sha1:f95350079cb0e93c57709b1166f969505dfd33a1</id>
<content type='text'>
The move_finalizers() routine checks each object in the unreachable
list to see if it has a finalizer.  If it does, it is moved to the
finalizers list.  The collector checks by calling, effectively,
hasattr(obj, "__del__").  The hasattr() call can result in an
arbitrary amount of Python code being run, because it will invoke
getattr hooks on obj.

If a getattr() hook is run from move_finalizers(), it may end up
resurrecting or deallocating objects in the unreachable list.  In
fact, it's possible that the hook causes the next object in the list
to be deallocated.  That is, the object pointed to by gc-&gt;gc.gc_next
may be freed before has_finalizer() returns.

The problem with the previous revision is that it followed
gc-&gt;gc.gc_next before calling has_finalizer().  If has_finalizer()
gc-&gt;happened to deallocate the object FROM_GC(gc-&gt;gc.gc_next), then
the next time through the loop gc would point to freed memory.  The
fix is to always follow the next pointer after calling
has_finalizer().

Note that Python 2.3 does not have this problem, because
has_finalizer() checks the tp_del slot and never runs Python code.

Tim, Barry, and I peed away the better part of two days tracking this
down.
</content>
</entry>
<entry>
<title>Backport for SF bug #574132:  Major GC related performance regression.</title>
<updated>2002-06-30T18:48:53Z</updated>
<author>
<name>Tim Peters</name>
<email>tim.peters@gmail.com</email>
</author>
<published>2002-06-30T18:48:53Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=9d8c8ff9ae28b0e0866a0a2b850cbcd32b9f9792'/>
<id>urn:sha1:9d8c8ff9ae28b0e0866a0a2b850cbcd32b9f9792</id>
<content type='text'>
2.2.1 has another bug that prevents the regression (which isn't a
regression at all) from showing up.  "The regression" is actually a
glitch in cyclic gc that's been there forever.

As the generation being collected is analyzed, objects that can't be
collected (because, e.g., we find they're externally referenced, or
are in an unreachable cycle but have a __del__ method) are moved out
of the list of candidates.  A tricksy scheme uses negative values of
gc_refs to mark such objects as being moved.  However, the exact
negative value set at the start may become "more negative" over time
for objects not in the generation being collected, and the scheme was
checking for an exact match on the negative value originally assigned.
As a result, objects in generations older than the one being collected
could get scanned too, and yanked back into a younger generation.  Doing
so doesn't lead to an error, but doesn't do any good, and can burn an
unbounded amount of time doing useless work.

A test case is simple (thanks to Kevin Jacobs for finding it!):

x = []
for i in xrange(200000):
    x.append((1,))

Without the patch, this ends up scanning all of x on every gen0 collection,
scans all of x twice on every gen1 collection, and x gets yanked back into
gen1 on every gen0 collection.  With the patch, once x gets to gen2, it's
never scanned again until another gen2 collection, and stays in gen2.

Opened another bug about that 2.2.1 isn't actually tracking (at least)
iterators, generators, and bound method objects, due to using the 2.1
gc API internally in those places (which #defines itself out of existence
in 2.2.x).
</content>
</entry>
<entry>
<title>backport tim_one's patch:</title>
<updated>2002-04-30T03:33:15Z</updated>
<author>
<name>Anthony Baxter</name>
<email>anthonybaxter@gmail.com</email>
</author>
<published>2002-04-30T03:33:15Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=07fb92a86f4428a0d1d827b6b18101afe77cdd15'/>
<id>urn:sha1:07fb92a86f4428a0d1d827b6b18101afe77cdd15</id>
<content type='text'>
(some tweaking for different _PyObject_GC_Malloc() call in 2.2. checked,
still returns the same thing on failure...)

_PyObject_GC_New:  Could call PyObject_INIT with a NULL 1st argument.
_PyObject_GC_NewVar:  Could call PyObject_INIT_VAR likewise.

Bugfix candidate.

Original patch(es):
python/dist/src/Modules/gcmodule.c:2.40
</content>
</entry>
<entry>
<title>The body of_PyObject_GC_UnTrack() should only be compiled #ifdef</title>
<updated>2002-04-03T14:07:32Z</updated>
<author>
<name>Guido van Rossum</name>
<email>guido@python.org</email>
</author>
<published>2002-04-03T14:07:32Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=50bfe3511283217001842615a58c15448f433351'/>
<id>urn:sha1:50bfe3511283217001842615a58c15448f433351</id>
<content type='text'>
WITH_CYCLE_GC.  (Neil pointed this out before the weekend, and I fixed
it right away, but forgot to check it in.)
</content>
</entry>
<entry>
<title>Backport to 2.2.1:</title>
<updated>2002-03-28T20:36:50Z</updated>
<author>
<name>Guido van Rossum</name>
<email>guido@python.org</email>
</author>
<published>2002-03-28T20:36:50Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=9ff1cf05fbcee1b98a4fc53ed12dc9b134a26f2f'/>
<id>urn:sha1:9ff1cf05fbcee1b98a4fc53ed12dc9b134a26f2f</id>
<content type='text'>
This is Neil's fix for SF bug 535905 (Evil Trashcan and GC interaction).

The fix makes it possible to call PyObject_GC_UnTrack() more than once
on the same object, and then move the PyObject_GC_UnTrack() call to
*before* the trashcan code is invoked.

BUGFIX CANDIDATE!
</content>
</entry>
<entry>
<title>Fix a bunch of typos found by nnorwitz.</title>
<updated>2002-02-06T17:06:03Z</updated>
<author>
<name>Michael W. Hudson</name>
<email>mwh@python.net</email>
</author>
<published>2002-02-06T17:06:03Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=fa338d7fad1c2e9f1c16849e9eac59ccfe9d878b'/>
<id>urn:sha1:fa338d7fad1c2e9f1c16849e9eac59ccfe9d878b</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Check for NULL return value of PyList_New (follow-up to patch #486743).</title>
<updated>2001-12-02T18:31:02Z</updated>
<author>
<name>Martin v. Löwis</name>
<email>martin@v.loewis.de</email>
</author>
<published>2001-12-02T18:31:02Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=f8a6f241b33310dee28e8f83d52a79f6ea84ceb9'/>
<id>urn:sha1:f8a6f241b33310dee28e8f83d52a79f6ea84ceb9</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Patch #486743: remove bad INCREF, propagate exception in append_objects.</title>
<updated>2001-12-02T12:21:34Z</updated>
<author>
<name>Martin v. Löwis</name>
<email>martin@v.loewis.de</email>
</author>
<published>2001-12-02T12:21:34Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=155aad17be54854bea6cafeb5177b19b4cb72bc6'/>
<id>urn:sha1:155aad17be54854bea6cafeb5177b19b4cb72bc6</id>
<content type='text'>
</content>
</entry>
</feed>
