SystemError while execing bad code

G

Gerrit Holl

Hi,

I found a cool way to trigger a SystemError:
XXX lineno: 0, opcode: 0
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/site-packages/", line 0, in
File "/usr/lib/python2.2/site-packages/", line 0, in
SystemError: unknown opcode

The documentation says:
You should report this to the author or maintainer of your Python
interpreter. Be sure to report the version of the Python interpreter
(sys.version; it is also printed at the start of an interactive Python
session), the exact error message (the exception's associated value) and
if possible the source of the program that triggered the error.

Although it probably shouldn't be taken literally in this case...
....or should it :)?

Hmm, and this actually *hangs*:XXX lineno: 2147483647, opcode: 0
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/site-packages/", line 2147483647, in

....

But I guess this is a case of "so don't do it" :)?

yours,
Gerrit.
 
P

Peter Hansen

Gerrit said:
I found a cool way to trigger a SystemError:

XXX lineno: 0, opcode: 0
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/site-packages/", line 0, in
File "/usr/lib/python2.2/site-packages/", line 0, in
SystemError: unknown opcode

The documentation says:
You should report this to the author or maintainer of your Python
interpreter. Be sure to report the version of the Python interpreter
(sys.version; it is also printed at the start of an interactive Python
session), the exact error message (the exception's associated value) and
if possible the source of the program that triggered the error.

Although it probably shouldn't be taken literally in this case...
...or should it :)?

Hmm, and this actually *hangs*:
XXX lineno: 2147483647, opcode: 0
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/site-packages/", line 2147483647, in

...

But I guess this is a case of "so don't do it" :)?

I once experimented, briefly, with doing "genetic programming" (evolving
programs to solve problems) using Python bytecode. In effect, this meant
that random sequences of bytes were being executed as though they were
valid compiled Python programs.

The interpreter crashed rapidly and frequently. I quickly concluded
that the interpreter is designed to be safe in executing bytecode that
is generated by a proper Python compiler, and that the compiler did not
generate random bytecodes most of the time.

Had to abandon that idea, though in principle it's still very cool.

-Peter
 
M

Michael Hudson

Gerrit Holl said:
Hi,

I found a cool way to trigger a SystemError:

How about marshal.loads('0') ?
XXX lineno: 0, opcode: 0
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/site-packages/", line 0, in
File "/usr/lib/python2.2/site-packages/", line 0, in
SystemError: unknown opcode [snippety]
But I guess this is a case of "so don't do it" :)?

Definitely. It's easy enought to crash the interpreter this way
(think LOAD_CONST 30000, for just one easy way).

Cheers,
mwh
 
S

Skip Montanaro

Gerrit> exec CodeType(0,0,0,0,"",(),(),(),"","",0,"")
...
Gerrit> But I guess this is a case of "so don't do it" :)?

Michael> Definitely. It's easy enought to crash the interpreter this
Michael> way (think LOAD_CONST 30000, for just one easy way).

In fact, help(types.CodeType) describes it thusly:

Create a code object. Not for the faint of heart.

Should this sort of stuff be published on the Wiki?

Skip
 
M

Michael Hudson

Skip Montanaro said:
Gerrit> exec CodeType(0,0,0,0,"",(),(),(),"","",0,"")
...
Gerrit> But I guess this is a case of "so don't do it" :)?

Michael> Definitely. It's easy enought to crash the interpreter this
Michael> way (think LOAD_CONST 30000, for just one easy way).

In fact, help(types.CodeType) describes it thusly:

Create a code object. Not for the faint of heart.

Should this sort of stuff be published on the Wiki?

I don't understand what you're suggesting here.

Cheers,
mwh
 

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,283
Messages
2,571,407
Members
48,101
Latest member
LinetteDeg

Latest Threads

Top