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

"Martin v. Löwis" martin at v.loewis.de
Wed May 12 15:38:34 EDT 2004


Greg Ewing wrote:
> Just a thought, but is statically verifying the bytecode even
> possible in principle? Seems to me it could be equivalent to
> the halting problem.

Reliably accepting all correct byte code, and rejecting all
incorrect one, would indeed be equivalent to the halting problem.

Therefore, byte code verification usually puts additional
constraints on byte code, rejecting some correct code as
unverifiable.

Then, in addition to the language spec, you also need to specify
what the verification rules are that an implementation needs to
follow.

The typical assumption is that you have "consistent" stack usage.
IOW, you need to be able to clearly identify start offsets of
byte code instructions, and associate a fixed stack depth with
each instruction. In typed languages, you also need to associate
a type with the TOS, and require that type to be consistent
across all possible execution paths. For example, in .NET
code verification, there is a requirement that the value stack
is empty at every branch target, and the start of every exception
handler.

IOW, it is only necessary that any byte code that the Python
byte code generator will ever emit verifies as correct. Accepting
additional byte codes is optional.

Regards,
Martin




More information about the Python-Dev mailing list