-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gc.get_referrers() is inherently dangerous #39117
Comments
gc.get_referrers() can be used to crash any Python Here is an example where an iterator can use it to from gc import get_referrers
def iter():
tag = object()
yield tag # 'tag' gets stored in the result tuple
lst = [x for x in get_referrers(tag)
if isinstance(x, tuple)]
t = lst[0] # this *is* the result tuple
print t # full of nulls !
tuple(iter()) Unless someone has more ideas than me as to how to |
Logged In: YES I guess it's dangerous to make object that is not properly |
Logged In: YES But it would be very difficult to fix the code base to avoid |
Logged In: YES I see no harm in your example. Even though the tuple has I fail to see how the example "crashes" the Python raise SystemError I recommend not to declare a function as "dangerous" in the |
Logged In: YES Martin, it's easy to transform the example into one that That said, it would be more helpful <wink> if Armin submitted |
Logged In: YES Here is the doc patch (attached). A clean solution to this problem would involve delaying GC |
Logged In: YES The wording Armin proposes in his patch makes sense to me. |
Logged In: YES Checked in: Doc/lib/libgc.tex (rev: 1.15) |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: