Re: [Python-Dev] r88178 - python/branches/py3k/Lib/test/crashers/underlying_dict.py
On Tue, 25 Jan 2011 01:00:28 +0100 (CET)
benjamin.peterson
Author: benjamin.peterson Date: Tue Jan 25 01:00:28 2011 New Revision: 88178
Log: another pretty crasher served up by pypy
Some comments would be nice. Right now it looks pretty close to deliberately obfuscated code (especially with the call to gc.get_referrers()). Regards Antoine.
On Tue, Jan 25, 2011 at 1:26 PM, Antoine Pitrou
On Tue, 25 Jan 2011 01:00:28 +0100 (CET) benjamin.peterson
wrote: Author: benjamin.peterson Date: Tue Jan 25 01:00:28 2011 New Revision: 88178
Log: another pretty crasher served up by pypy
Some comments would be nice. Right now it looks pretty close to deliberately obfuscated code (especially with the call to gc.get_referrers()).
Regards
Antoine.
I gets to a dict of class circumventing dictproxy. It's yet unclear why it segfaults.
Le mardi 25 janvier 2011 à 20:11 +0200, Maciej Fijalkowski a écrit :
On Tue, Jan 25, 2011 at 1:26 PM, Antoine Pitrou
wrote: On Tue, 25 Jan 2011 01:00:28 +0100 (CET) benjamin.peterson
wrote: Author: benjamin.peterson Date: Tue Jan 25 01:00:28 2011 New Revision: 88178
Log: another pretty crasher served up by pypy
Some comments would be nice. Right now it looks pretty close to deliberately obfuscated code (especially with the call to gc.get_referrers()).
Regards
Antoine.
I gets to a dict of class circumventing dictproxy. It's yet unclear why it segfaults.
Perhaps the method cache? But why the comment "# should print 1"? Shouldn't it print 2 instead?
I gets to a dict of class circumventing dictproxy. It's yet unclear why it segfaults.
The crash as well as the output "1" are both caused because updating the class dictionary directly doesn't invalidate the method cache. When the new value for "f" is assigned to the dict, the old "f" gets garbage collected (because the method cache uses borrowed references), but there is still an entry in the cache for the (now garbage-collected) function. When "a.f" is executed next, the entry of the cache is used and a new method is created. When that method gets called, it returns "1" and when the interpreter tries to garbage collect the new method on interpreter finalization, it segfaults because the referenced "f" is already collected. Regards, Andreas
Some comments would be nice. Right now it looks pretty close to deliberately obfuscated code (especially with the call to gc.get_referrers()).
That call tries to get at the class dictionary, rather then just the dict_proxy that you get from A.__dict__. There should be two referrers to thingy: the class dict, and the module dict. The class dict will have a __module__ key. I agree the program should print 2, though. Regards, Martin
participants (4)
-
"Martin v. Löwis"
-
Andreas Stührk
-
Antoine Pitrou
-
Maciej Fijalkowski