[Python-Dev] another dict crasher

Michael Hudson mwh@python.net
01 Jun 2001 19:52:17 +0100


Warning!  VERY SICK CODE INDEED ahead!

barry@digicool.com (Barry A. Warsaw) writes:

> >>>>> "MH" == Michael Hudson <mwh@python.net> writes:
> 
>     MH> segfaults both 2.1 and current (well, maybe a day old) CVS.
>     MH> Haven't tried Tim's latest patch, but I don't believe that
>     MH> will make any difference.
> 
> That is highly, highly nasty.

Not as nasty as this, though:

dict = {}

# let's force dict to malloc its table
for i in range(1,10):
    dict[i] = i

class Machiavelli:
    def __repr__(self):
        dict.clear()
        print # doesn't crash without this.  don't know why
        return `"machiavelli"`
    def __hash__(self):
        return 0

dict[Machiavelli()] = Machiavelli()

print dict

gives, even with my posted patch to dictobject.c

$ ./python crash2.py
{
Segmentation fault (core dumped)

Any ideas what the above code should do?  (Other than use the secret
PSU website to hire a hitman and shoot whoever wrote the code, I
mean).

Cheers,
M.

-- 
  Well, yes.  I don't think I'd put something like "penchant for anal
  play" and "able to wield a buttplug" in a CV unless it was relevant
  to the gig being applied for...
                                 -- Matt McLeod, alt.sysadmin.recovery