python core dump (SIGBUS) on Solaris

Andrew M. Kuchling akuchlin at mems-exchange.org
Thu Jul 8 09:24:33 EDT 1999


Gary Pennington - UK Performance Centre writes:
>It would be more efficient to assume that you are processing a string and
>only try to unpickle if the string is detected as a pickle. The tricky bit
>is detecting that it is a pickled object in the string. Does a pickled
>string start with some kind of magic sequence?

	Unfortunately, there's no magic sequence in pickles.  The
relevant function in Cookie.py is: def _debabelize(val, loads=loads):
    str = _unquote(val)
    try:
        return loads(str)
    except:
        return str

Which is fine if loads() just chokes on bad input and raises an
exception, but not if it dumps core.  I don't see how to change this
behaviour in Cookie.py without breaking backward compatibility by
turning unpickling off by default, so maybe someone should look at
fixing cPickle.  The bug seems to be a memory overrun, because it
doesn't fail on the first attempt:

amarok Python-1.5>./python
Python 1.5.2+ (#82, Jun 17 1999, 09:53:36)  [GCC 2.8.1] on sunos5
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import cPickle
>>> cPickle.loads('garyp')
Traceback (innermost last):
  File "<stdin>", line 1, in ?
cPickle.BadPickleGet: path
>>> cPickle.loads('garyp')
Bus Error (core dumped)

-- 
A.M. Kuchling			http://starship.python.net/crew/amk/
The biggest difference between Heaven's Gate and mainstream Christianity is
that the Heaven's Gate people never tried to brainwash my kids.
    -- Rev. Ivan Stang





More information about the Python-list mailing list