[LLVMdev] Exception handling question
baldrick at free.fr
Fri Jan 22 05:20:03 PST 2010
> Thanks but I've also tried calling both a separate C function that then
> calls _Unwind_RaiseException and also a C++ function that throws an
> integer with the same results. I've also just tried running the example
> code posted earlier by Duncan and I find that doesn't reach the landing
> pad either if g() is replaced with a C++ function containing "throw 1".
if all personality functions up the call chain return "cleanup" (i.e. not
_URC_HANDLER_FOUND), then _Unwind_RaiseException returns without doing
anything, i.e. without running any cleanups. I understand that this is
considered to be a feature rather than a bug... If you want to run cleanups
anyway, then you need to do a "forced unwind" when _Unwind_RaiseException
returns like this. Note that this means that the decision to run cleanups is
under the control of whoever is throwing the exception in this case (for example
C++'s throw logic doesn't do this, so cleanups are not run if there are only
cleanups and no handlers - I'm not sure why C++ considers it so important to
have programs exit swiftly that it doesn't bother running potentially vital
cleanups...). Alternatively, have your personality function return
_URC_HANDLER_FOUND when it finds a cleanup [*].
[*] Though since you said your personality function is not called at all,
I guess this won't help solve your problem...
More information about the llvm-dev