[Pythonmac-SIG] Catching exceptions inside python with catch_exception_raise() doesn't work

Ronald Oussoren ronaldoussoren at mac.com
Tue Dec 12 10:44:26 CET 2006


Hi,

I haven't used the raw mach API's yet, so can't help you here. I must  
say that this looks like a pretty evil API. I wonder why they didn't  
use a manually passed in callback function like sane APIs.

Ronald

On Dec 11, 2006, at 11:43 PM, Charlie Miller wrote:

> Is it possible to monitor for exceptions using the Mac OS X
> catch_exception_raise function inside python?  As you may know, after
> some setup, this function gets called whenever an exception occurs.
> I have a program which works great in C but when I wrap it in python
> it fails.  This is due to the fact that it calls exc_server, which
> uses _dyld_lookup_and_bind, to try to find the location of the
> function catch_exception_raise.  When wrapped in python,
> dyld_lookup_and_bind returns 0x2030 which is NOT the correct
> address.  It then jumps there and tries executing which causes a BUS
> ERROR.
>
> In C at least, dyld_lookup_and_bind works if the
> catch_exception_raise function is compiled into the binary or linked
> dynamically at runtime via a shared library (dylib).  However, it
> doesn't work if it is brought into the executable space via dlopen -
> which presumably is how python does it.
>
> How can I set it up so that I can monitor applications for exceptions
> in a python script?  I could fork and exec a program with its own
> address space, but that seems ridiculous.  I could recompile the
> python interpreter and include catch_exception_raise, but that also
> seems terrible.  Or is it impossible to wrap such a program in python
> - which seems silly?
>
> Any help is appreciated.  Thanks,
>
> Charlie
>
>
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3562 bytes
Desc: not available
Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20061212/7788113d/attachment.bin 


More information about the Pythonmac-SIG mailing list