[libc++] Use the no_destroy attribute to avoid destroying debug DB statics
Summary:
Otherwise, we can run into problems when the program has static variables
that need to use the debug database during their deinitialization, if
the debug DB has already been deinitialized.
Reviewers: EricWF
Subscribers: christof, jkorous, dexonsmith, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D60830
llvm-svn: 358602
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 81875a67b0d1bd43cca96b5e321a4af06b9299cd
diff --git a/src/debug.cpp b/src/debug.cpp
index 93fa1a8..7fdf90c 100644
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -42,7 +42,7 @@
__libcpp_db*
__get_db()
{
- static __libcpp_db db;
+ static _LIBCPP_NO_DESTROY __libcpp_db db;
return &db;
}
@@ -64,7 +64,7 @@
mutex_type&
mut()
{
- static mutex_type m;
+ static _LIBCPP_NO_DESTROY mutex_type m;
return m;
}
#endif // !_LIBCPP_HAS_NO_THREADS