Nat! bio photo


Senior Mull.

Twitter RSS


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] //
myClassMethodBouncer //
function_with_a_callback //
-[MyClass waitingForAnException] //
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 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.