carshing the interpreter in two lines

G

gangesmaster

the following (random) code crashes my interpreter
(python 2.4.3/winxp):

from types import CodeType as code
exec code(0, 5, 8, 0, "hello moshe", (), (), (), "", "", 0, "")

i would expect the interpreter to do some verifying, at least for
sanity (valid opcodes, correct stack size, etc.) before executing
artbitrary code... after all, it was the BDFL who said """I'm not
saying it's uncrashable. I'm saying that if you crash it, it's a
bug unless proven harebrained."""


-tomer
 
S

sam

tomer:

It is my opinion that you would loose performance if the Python
interpreter had the additional task of verifying byte code. It might be
more appropriate to have a preprocessor that did the verifying as it
compiled the byte code.

Sam Schulenburg
 
M

Mel Wilson

sam said:
tomer:

It is my opinion that you would loose performance if the Python
interpreter had the additional task of verifying byte code. It might be
more appropriate to have a preprocessor that did the verifying as it
compiled the byte code.

Possibly. A good book on the topic is Douglas Hofstadter's
_Goedel, Escher, Bach: an Eternal Golden Braid_.

Particularly starting from the chapter "Contracrostipunctus".

Cheers, Mel.
 
A

Alex Martelli

sam said:
tomer:

It is my opinion that you would loose performance if the Python
interpreter had the additional task of verifying byte code. It might be
more appropriate to have a preprocessor that did the verifying as it
compiled the byte code.

But in this case, there is no "compiled" -- just the code type's
constructor:

Yes, code() itself could do some sanity checking. But so could 'exec'
-- it's never a particularly fast operation anyway... and most
definitely NOT on the critical path of normal operations. I'd rather
have "defense in depth", in this case.


Alex
 
S

sam

Mel:
Wow that book brings back memories. I scanned my copy to review the
subject covered, and came to the conclusion that mind reading
algorithms are the answer.

Sam Schulenburg
 
M

Mel Wilson

sam said:
Mel:
Wow that book brings back memories. I scanned my copy to review the
subject covered, and came to the conclusion that mind reading
algorithms are the answer.
I gathered from somewhere (but not the index to Andrew
Hodges' biography) that Turing was toying with an idea for
"oracles", where a computation would be allowed to call out
sometimes to a non-computational process to obtain some
required result. Used maybe by interactive debugging programs.

Cheers, Mel.
Mel Wilson wrote: [ ... ]
Douglas Hofstadter's _Goedel, Escher, Bach: an Eternal Golden Braid_. [ ... ]
"Contracrostipunctus".
 
A

Aahz

the following (random) code crashes my interpreter
(python 2.4.3/winxp):

from types import CodeType as code
exec code(0, 5, 8, 0, "hello moshe", (), (), (), "", "", 0, "")

i would expect the interpreter to do some verifying, at least for
sanity (valid opcodes, correct stack size, etc.) before executing
artbitrary code... after all, it was the BDFL who said """I'm not
saying it's uncrashable. I'm saying that if you crash it, it's a
bug unless proven harebrained."""

IIRC, this has been discussed before and deemed harebrained. Check SF to
see whether this specific case has been submitted previously and submit
it if not. Then post to python-dev if it's a new bug and ask for a
ruling on whether it's harebrained.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,297
Messages
2,571,536
Members
48,284
Latest member
alphabetsalphabets

Latest Threads

Top