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

Armin Rigo arigo at tunes.org
Wed May 12 07:01:39 EDT 2004


Hello Tim,

On Tue, May 11, 2004 at 11:39:57PM -0400, Tim Peters wrote:
> Verifying what, precisely?  (...) and that no jump tries to branch into
> the middle of some multi-byte opcode sequence

Why not?  :-)  (mwh can surely recommend me a psy)

> Harder to do is flow-sensitive eval stack
> simulation, to ensure that no path through the code can push more on the
> eval stack than was allocated for it, and that there's enough stuff on the
> stack at each point to satisfy each opcode that requires accessing the eval
> stack.

There are a few opcodes whose effect on the stack isn't self-contained, like
MAKE_FUNCTION which will pop N cell variables off the stack, for N loaded from
the code object which itself comes from the stack.  These ones are fun to
analyse.

Even without these, checking if a bytecode could possibly over/underflow the
stack is indeed equivalent to the halting problem; a silly example:

    <some algorithm which may stop or not>
    POP_TOP

This underflows the stack if and only if the algorithm stops.


Armin



More information about the Python-Dev mailing list