« December 2011 | Main | February 2012 »

January 2012 Archives

January 6, 2012

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.

About January 2012

This page contains all entries posted to Nat!'s Web Journal in January 2012. They are listed from oldest to newest.

December 2011 is the previous archive.

February 2012 is the next archive.

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