[Patches] [ python-Patches-1517042 ] Fix for Lib/test/crashers/gc_inspection.py

SourceForge.net noreply at sourceforge.net
Fri Aug 4 11:19:23 CEST 2006


Patches item #1517042, was opened at 2006-07-04 17:39
Message generated for change (Comment added) made by mwh
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1517042&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: Core (C code)
Group: Python 2.5
Status: Open
Resolution: None
Priority: 2
Submitted By: Collin Winter (collinwinter)
>Assigned to: Neal Norwitz (nnorwitz)
Summary: Fix for Lib/test/crashers/gc_inspection.py

Initial Comment:
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).

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

>Comment By: Michael Hudson (mwh)
Date: 2006-08-04 10:19

Message:
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.

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

Comment By: Armin Rigo (arigo)
Date: 2006-07-25 19:08

Message:
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.

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

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-07-06 07:28

Message:
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.

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

Comment By: Raymond Hettinger (rhettinger)
Date: 2006-07-05 23:31

Message:
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.

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

Comment By: Collin Winter (collinwinter)
Date: 2006-07-05 18:36

Message:
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.

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1517042&group_id=5470


More information about the Patches mailing list