[libcxx-dev] Static initialization order potential issue in libcxxabi

Idan Freiberg via libcxx-dev libcxx-dev at lists.llvm.org
Wed Dec 11 23:43:30 PST 2019


Yes, it works. The `constexpr` actually fixes the as _LIBCPP_SAFE_STATIC
doesn't make any difference when building with gcc.

Thanks.

On Thu, Dec 12, 2019 at 5:47 AM Eric Fiselier <eric at efcs.ca> wrote:

> I've committed a fix, though I was unable to reproduce the problem with
> unit tests.
>
>
> https://github.com/llvm/llvm-project/commit/a9245e4f86165ac38a297138fff08cd4eb7255a7
>
> Could you please confirm it on your end?
>
> On Sun, Dec 8, 2019, 6:52 AM Idan Freiberg via libcxx-dev <
> libcxx-dev at lists.llvm.org> wrote:
>
>> Hello,
>>
>> I believe iv'e identified an issue with libcxxabi.
>> The symptom is that, when calling std::treminate() on some simple
>> program, the program segfaults.
>>
>> After a bit of debugging libcxxabi, Iv'e noticed that
>> `__cxa_terminate_handler` is NULL at program initialization. However,
>> calling std::set_terminate(nullptr); sets the actual default terminate
>> handler (in my case is just std::abort).
>>
>> I tend to believe this is related to an static initialization order
>> issue, in which `__cxa_terminate_handler`  doesn't not get this correct
>> value of std::abort (set by default_terminate_handler).
>>
>> https://github.com/llvm/llvm-project/blob/master/libcxxabi/src/cxa_default_handlers.cpp#L96
>>
>> One solution for iv'e found is wrapping the default_terminate_handler
>> with a function and set this function as __cxa_terminate_handler first.
>>
>> I would be happy to hear your insights about this.
>>
>> --
>> Idan Freiberg
>> Mobile: +972-52-2925213
>> _______________________________________________
>> libcxx-dev mailing list
>> libcxx-dev at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/libcxx-dev
>>
>

-- 
Idan Freiberg
Mobile: +972-52-2925213
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/libcxx-dev/attachments/20191212/5fe24165/attachment.html>


More information about the libcxx-dev mailing list