[Pythonmac-SIG] Restrictions on what you can do in a Python module?

Bob Ippolito bob at redivi.com
Wed Aug 27 12:56:45 EDT 2003


On Wednesday, Aug 27, 2003, at 11:40 America/New_York, Robb Brown wrote:

> I'm trying to write wrappers for dcmtk (a toolkit for the medical 
> imaging DICOM standard).  At the moment I have three functions, to 
> open an association (basically a network connection), close it, and 
> send an echo request (like a ping).  A test program written entirely 
> in C works fine but when compiled as a module and called from Python I 
> get an illegal instruction when the dcmtk function to actually open 
> the association is called.  I believe this function is simply opening 
> a socket, connecting to a server and negotiating what flavour of the 
> protocol to use.
>
> Are there things that simply can't be done in a Python module?  What 
> exactly is an illegal instruction?

Illegal instruction is a CPU level exception.  What it means is that 
the CPU tried to execute invalid opcode.  It has nothing to do with 
security or Python.  Generally what it means that some branch 
instruction told the CPU to go somewhere that wasn't code at all, which 
can happen if you have a corrupted stack or function pointer.

In any case, this is almost certainly a bug in your wrapper.  If dcmtk 
uses threads you might not be doing the right thing with thread states 
from Python, otherwise you've just got some bad C code somewhere.  If 
you post the code you have, someone might look at it.

-bob




More information about the Pythonmac-SIG mailing list