473,625 Members | 3,329 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SystemError while execing bad code

Hi,

I found a cool way to trigger a SystemError:
exec CodeType(0,0,0, 0,"",(),(),()," ","",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

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*: exec CodeType(0,0,0, 0,"",(),(),()," ","",2**31-1,"")

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.

--
263. If he kill the cattle or sheep that were given to him, he shall
compensate the owner with cattle for cattle and sheep for sheep.
-- 1780 BC, Hammurabi, Code of Law
--
PrePEP: Builtin path type
http://people.nl.linux.org/~gerrit/c.../pep-xxxx.html
Asperger's Syndrome - a personal approach:
http://people.nl.linux.org/~gerrit/english/

Jul 18 '05 #1
4 3055
Gerrit Holl wrote:

I found a cool way to trigger a SystemError:
exec CodeType(0,0,0, 0,"",(),(),()," ","",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

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*: exec CodeType(0,0,0, 0,"",(),(),()," ","",2**31-1,"")

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
Jul 18 '05 #2
Gerrit Holl <ge****@nl.linu x.org> writes:
Hi,

I found a cool way to trigger a SystemError:
How about marshal.loads(' 0') ?
exec CodeType(0,0,0, 0,"",(),(),()," ","",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

--
Very clever implementation techniques are required to implement this
insanity correctly and usefully, not to mention that code written
with this feature used and abused east and west is exceptionally
exciting to debug. -- Erik Naggum on Algol-style "call-by-name"
Jul 18 '05 #3

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.Code Type) describes it thusly:

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

Should this sort of stuff be published on the Wiki?

Skip

Jul 18 '05 #4
Skip Montanaro <sk**@pobox.com > writes:
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.Code Type) 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

--
Python enjoys making tradeoffs that drive *someone* crazy <wink>.
-- Tim Peters, comp.lang.pytho n
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3336
by: Jeroen | last post by:
Hi, I'm searching but not finding :( I need the code that creates automatic the days in a month So like for this month, it creates the days in this format 01-Oct, 02-Oct, .... This should be used in a form so when opening the page, automatic all the
18
7532
by: Phill Long | last post by:
this is the the code, now here is the final result.... I get one combo box and one tex box come up, but they are empty... DAMN!!! Any ideas on what Im doing wrong please.. Thanks Again <?php require_once('..\library_database\Connections\onlinequote.php'); ?> <?
12
8171
by: lawrence | last post by:
I have a string which I want to send to eval(). How can I test it ahead of time to make sure it is valid code? I don't want to send it to eval and get parse errors. I want to do something like this: $valid = checkPHP($string); if ($valid) { eval($string); } else { $resultsObject->addToErrorResults("We wanted to send our template to eval(), but the PHP it contained was invalid.");
51
5250
by: Mudge | last post by:
Please, someone, tell me why OO in PHP is better than procedural.
9
4147
by: alban.minassian | last post by:
(Sorry for my bad english ) I convert a php code to python. i have 10000 lines where i add and add and add string.... like var += "xxxxxx" And line 5139 i have SystemError: com_backpatch: offset too large. All work except if i exceed line 5139 ! I dont find solution. I have only found this post...
1
3855
by: Newgene | last post by:
Hi, group, I am trying to dynamically add a method to class by following this post: http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/2ec2ad7a0a5d54a1/928e91be352c6bfc?q=%22new.code(%22+%22import+new&_done=%2Fgroup%2Fcomp.lang.python%2Fsearch%3Fgroup%3Dcomp.lang.python%26q%3D%22new.code(%22+%22import+new%26qt_g%3D1%26&_doneTitle=Back+to+Search&&d#928e91be352c6bfc But I got the Error like the below: ...
2
2648
by: robert | last post by:
From the trace of a 2.3.5 software i got: \'SystemError: C:\\\\sf\\\\python\\\\dist23\\\\src\\\\Objects\\\\cellobject.c:22: bad argument to internal function\\n\'] from the middle of normal function / or its call. What is this?
6
2348
by: usenet1 | last post by:
I'm a newbie with hopefully an easy question. I'm trying to write some "C" code that will run a python script that can in turn call some "C" functions. However I'm having a problem getting started because although I can run a script from the python ide that imports ctypes, when I execute that 'import ctypes' code from the "C" code I get the following error: 'import site' failed; use -v for traceback Traceback (most recent call last):
11
10811
by: zefciu | last post by:
I am trying to embed a c function in my python script for a first time. When I try to call it I get an error SystemError: new style getargs format but argument is not a tuple Guido said on some mailing list, that it is probably an effect of the lack of METH_VARARGS in the functions' array, but it's ok in my source code. Here is the full code: #include <python2.4/Python.h>
0
8189
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8694
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7184
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4089
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1500
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.