[Python-Dev] Is core dump always a bug? Advice requested

Robert Brewer fumanchu at amor.org
Mon May 10 12:44:19 EDT 2004


Terry Reedy wrote:
> 
> The following was posted in the last 25 hours on c.l.p:
> 
> "Xaver Hinterhuber" <xaver_hinterhuber at web.de> wrote in message
> news:c7o6al$i1j$1 at online.de...
> >     codeObject = new.code(
> >       0, # argcount
> >       0, # nlocals
> >       0, # stacksize
> >       0, # flags
> >       codeString, # code
> >       (), # consts
> >       (), # names
> >       (), # varnames
> >       'content', # filename
> >       'content', # name
> >       3, # first line number
> >       codeString # lnotab
> >       )
> >     f = new.function(codeObject, dict, 'f')
> >     f()
> >
> > Everything runs fine, until the function is called with f().
> > When python tries to execute f(), the core dump happens.
> > I don't have any clue why python core dumps.
> > The codeString is nothing complex, its a one-liner.
> 
> ... but, as too typical of new posters, not posted ;-)
> 
> My question: I understand that core dumping by the Python 
> interpreter is
> normally considered a bug -- one that should be reported on SF -- and
> fixed.  But does that principle apply to this sort of use (or probably
> abuse) of the new module.  In other words, does the 'no core 
> dump' contract
> include a 'byte code compiled by the interpreter' proviso.  
> Or is ceval
> intended to be robust against random strings masquerading as 
> valid byte
> code (which would seem require an InvalidByteCode exception). 
>  Or in still
> other words, is there a bug that I should encourage reporting 
> of, or is
> 'don't do that' the extent of a proper response?

There are other problems; once I passed a unicode string in co_names--it
took me quite a while to track down THAT mistake. :) Perhaps some more
rigorous assertions, returning ValueErrors? If not in C, then in the
'new' module, since that seems to be the vector of disaster for Xaver,
above. Perhaps this would also be an argument for keeping the 'new'
module around longer, as a 'safer' Pythonic wrapper over bare
code/function construction.


Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org



More information about the Python-Dev mailing list