[llvm-bugs] [Bug 44252] New: default_terminate_handler / default_unexpected_handler is not always set due to static initialization order fiasco
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Dec 9 00:10:36 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=44252
Bug ID: 44252
Summary: default_terminate_handler / default_unexpected_handler
is not always set due to static initialization order
fiasco
Product: libc++abi
Version: 8.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: unassignedbugs at nondot.org
Reporter: speidy at gmail.com
CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
Hi,
Iv'e build libcxxabi using gcc-musl toolchain iv'e downloaded from:
http://musl.cc/x86_64-linux-musl-cross.tgz.
When using libcxxabi built by the mentioned toolchain, iv'e noticed that call
to std::terminate() will crash the program.
However, a call to `std::set_terminate(nullptr);` first, will actually set the
default_terminate_handler to the right one (in my case std::abort), then
another call to std::terminate() will succeed.
After a bit of debugging libcxxabi, Iv'e noticed that `__cxa_terminate_handler`
is NULL at program initialization.
I tend to believe this is related to a static initialization order issue, in
which `__cxa_terminate_handler` doesn't not get the correct value of
`default_terminate_handler` (which should be statically initialized to some
handler func, such as std::abort).
https://github.com/llvm/llvm-project/blob/master/libcxxabi/src/cxa_default_handlers.cpp#L96
This is true for `__cxa_unexpected_handler` as well.
Note: when building libcxxabi with clang++, the issue does not occur.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191209/4e9bd347/attachment.html>
More information about the llvm-bugs
mailing list