« Measuring context switches :: a small expedition. Part IV | Main | My Kimble Moment with Ducks and Superducks in Rocksmith (PS3) »

Using --eh-frame-header when using -fobjc-exceptions GNU/Linux: good, but not necessarily good enough

This is on Linux, with the gcc compiler (4.6). Not OS X.

When you compile code with -fobjc-exceptions, you presumably do that to somewhere execute a throw. Lets say, this is my callstack:

abort// glibc
objc_exception_throw// libobjc
-[MyClass methodThrowingAnException]// myclass.so
myClassMethodBouncer// myclass.so
function_with_a_callback// thirdparty.so
-[MyClass waitingForAnException]// myclass.so
main// main

What has happened ? I compiled all the MyClass code with -fobjc-exceptions and even did not forget to link the resulting shared library with --eh-frame-header. So all my code and libobjc.so has PT_GNU_EH_FRAME information, which is necessary for the "modern" C++ like stack unwinding.

Still not good enough. The third party library code function_with_a_callback, was not linked with --eh-frame-header and the unwinding stops right there. No catch handler can be found and objc_exception_throw treats this as an uncaught exception.

An example for the rule, that with every increase of complexity, there is also an increase in brittleness.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on January 6, 2012 5:41 PM.

The previous post in this blog was Measuring context switches :: a small expedition. Part IV.

The next post in this blog is My Kimble Moment with Ducks and Superducks in Rocksmith (PS3).

Many more can be found on the main index page or by looking through the archives.