Re: checking arbitrary bytecode for potential crashes

PJ Eby <pje-Wh6+Hckhi6HFNGf7iClzIwC/[email protected]> Tue, 30 Sep 2014 20:16:29 -0400
Newsgroups gmane.comp.python.peak
Message-ID <CALeMXf7PX3OU=qkoP4G13MPsZsaY_0tiNb-NUbx_48ueMvMXWg@mail.gmail.com>
On Tue, Sep 30, 2014 at 4:57 AM, Dima Tisnek <[email protected]> wrote:
> Hi all,
>
> BytecodeAssembler mentions that "It should now be virtually impossible
> to accidentally generate bytecode that can crash the interpreter. (If
> you find a way, let me know!)"
>
> How do I invoke this validation?
>
> Here's a simplest example after ned and lvh:
>
> code_obj = peak.util.assembler.code(0, 0, 1, 0, "KABOOM", (), (), (),
> "gooo", "goo", 1, "l")

That doesn't look accidental to me.  That looks like you did it on purpose.  ;-)

To elaborate:

* There is no validation for raw bytecode -- it's Bytecode*Assembler*,
not RawBytecodeVerifier  ;-)
* It's simple stack-level validation and dead-code prevention, not
security validation
* As it says, it's intended to prevent *accidental* crashing code
caused by bugs in your bytecode generation process using the opcode or
AST APIs.

;-)