segfault. which module to blame? (entire traceback)

D-Man dsh8290 at rit.edu
Fri Feb 16 13:43:34 EST 2001


On Fri, Feb 16, 2001 at 05:21:30PM +0000, Dan Parisien wrote:
[snip]
| segfaults before while coding normal python scripts. I think it was the 
| dictionaries because that's pretty much all I used. Could it be bad 
| reference counting in those? I would have to read the code, but could there 
| be a problem if two keys hashed to the same value in the dictionary and 
| that one is deleted before the other or something similar?

I'll find out by making a class that always hashes to the same value :

class Hashable :
...     def __hash__( self ) :
...             return 5
...
>>> h1 = Hashable()
>>> h2 = Hashable()
>>> id( h1 )
8185684
>>> id( h2 )
8182548
>>> d = { }
>>> d[ h1 ] = 1
>>> d[ h2 ] = 2
>>> print d
{<__main__.Hashable instance at 007CE754>: 1, <__main__.Hashable
instance at 007CDB14>: 2}
>>>
>>> del d[ h1 ]
>>> print d
{<__main__.Hashable instance at 007CDB14>: 2}
>>> del d[ h2 ]
>>>


It didn't crash for me (Win2k, Python 2.0) when I had 2 keys with the
same hash value.

-D





More information about the Python-list mailing list