This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Fix for Lib/test/crashers/gc_inspection.py
Type: Stage:
Components: Interpreter Core Versions: Python 2.5
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: nnorwitz Nosy List: arigo, collinwinter, georg.brandl, mwh, nnorwitz, rhettinger
Priority: low Keywords: patch

Created on 2006-07-04 16:39 by collinwinter, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fix_gc_inspection.patch collinwinter, 2006-07-04 16:39 Fix for crashers/gc_inspection.py, against r47225
Messages (7)
msg50600 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2006-07-04 16:39
The attached patch fixes the bug pointed out in
crashers/gc_inspection.py, namely that
gc.get_referrers() can be used to see objects (in this
case tuples) before their built, leading to segfaults.

The patch works by modifying
Objects/abstract.c:PySequence_AsTuple, wrapping the
call to PyIter_Next() with _PyObject_GC_TRACK/UNTRACK
calls. This has the effect of hiding the being-created
tuple from gc.get_referrers() while fetching the next
item from the iterator.

Also attached is a patch to crashers/gc_inspection.py
itself, which allows the test to actually pass (the
previous version would raise IndexErrors in the event
the test passed).
msg50601 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2006-07-05 17:36
Logged In: YES 
user_id=1344176

The improve_gc_inspection.patch file has been superseded by
a patch attached to bug #1517663. The bug details another
interpreter crash in the same vein as the one fix in tuple()
by this patch.
msg50602 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2006-07-05 22:31
Logged In: YES 
user_id=80475

Crashers based on gc.get_referrers() should not be 
considered real bugs.  It is certainly not worth 
complexifying the code or slowing it down just to preclude 
these little perverse safe-cracking exercises.  Also, it 
is not worth the risk of introducing a real bug when the 
code was working fine.  

That being said, if the code is genuinely defective and 
has potential to cause real-world problems, then it should 
be fixed.  I would think that if there were a long-
standing problem with tuples, it would have manifested 
itself long ago.
msg50603 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2006-07-06 06:28
Logged In: YES 
user_id=33168

Note that the declaration of item needs to be moved to the
top of the scope so it can compile with C89.
msg50604 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2006-07-25 18:08
Logged In: YES 
user_id=4771

This patch is pointless.  I recommend rejecting it.
The crashers/gc_inspection.py was just one example among
many of crashing Python with gc.get_referrers().  I don't
see why we should care to fix just this specific way.

What would be needed is a complete review, possibly with
an API change to decouple object creation and GC
registration, and appropriate documentation for extension
module writers.  I don't think it's likely to happen though.
msg50605 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2006-08-04 09:19
Logged In: YES 
user_id=6656

I agree with arigo.  Assigning to Neal so he can see this and get it off his "things 
to do for 2.5" list.
msg50606 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-10-12 13:02
Logged In: YES 
user_id=849994

Closing as well as bug #1517663.
History
Date User Action Args
2022-04-11 14:56:18adminsetgithub: 43611
2006-07-04 16:39:01collinwintercreate