[cfe-dev] [libcxxabi]: why does not the default unexpected handler call terminate() in libcxxabi?
Howard Hinnant
hhinnant at apple.com
Tue Sep 18 07:49:39 PDT 2012
On Sep 18, 2012, at 6:28 AM, soaliap <soaliap at 126.com> wrote:
> When I executed testsuites in
> libcxx/test/depr/exception.unexpected/set.unexpected directory, it failed to
> verify the default unexpected handler.
> I saw the code in libcxx/src/exception.cpp:
> ----------------------------------------------------------------------
> #if __APPLE__
> //...
> #elif defined(LIBCXXRT) || __has_include(<cxxabi.h>)
> // ...
> #else // __has_include(<cxxabi.h>)
> static std::terminate_handler __terminate_handler;
> static std::unexpected_handler __unexpected_handler; // default value is 0
> #endif // __has_include(<cxxabi.h>)
> ----------------------------------------------------------------------
> __unexpected_handler is a static varible, so its default value is 0, then I
> plan to use the __cxa_unexpected_handler in libc++abi instead of
> __unexpected_handler. But its default value is default_unexpected_handler,
> and it indirectly calls abort_message() rather than std::terminate().
>
> I saw the section "D.11.1 Type unexpected_handler" of n3242.pdf, it says:
> "Default behavior: The implementation's default unexpected_handler calls
> terminate()."
> Now I'm confused about why the default unexpected handler does not call
> terminate() in libcxxabi.
>
> I think it's the reason causes the two testsuites failed:
> ----------------------------------------------------------------------
> (1)
> libcxx/test/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp
> (2)
> libcxx/test/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp
> ----------------------------------------------------------------------
>
> Is it a bug of libc++abi, or I misunderstood it? Who can give me some
> advice? Thanks very much!
I believe the bottom line is that libcxx/libcxxabi hasn't been ported to your platform. The 3rd #else/#endif branch in libcxx/src/exception.cpp is not being used by anyone that I'm aware of.
I recommend getting into the branch __has_include(<cxxabi.h>) which will #define _LIBCPPABI_VERSION (which comes from libcxxabi. But this is porting work you (or someone) will have to do.
Howard
More information about the cfe-dev
mailing list