diff --git a/td/telegram/Client.cpp b/td/telegram/Client.cpp index f5f6206a6..0f3e3ce05 100644 --- a/td/telegram/Client.cpp +++ b/td/telegram/Client.cpp @@ -19,7 +19,7 @@ #include "td/utils/port/RwMutex.h" #include "td/utils/port/thread.h" -#include "death_handler.h" +#include "td/utils/death_handler.h" #include #include diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index a7d699928..dd58fb4fc 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -38,7 +38,7 @@ #include "td/utils/StringBuilder.h" #include "td/utils/Time.h" -#include "death_handler.h" +#include "td/utils/death_handler.h" #ifndef USE_READLINE #include "td/utils/find_boundary.h" diff --git a/tdutils/CMakeLists.txt b/tdutils/CMakeLists.txt index 504ae8e5c..7d5a9a1a8 100644 --- a/tdutils/CMakeLists.txt +++ b/tdutils/CMakeLists.txt @@ -259,6 +259,8 @@ set(TDUTILS_SOURCE td/utils/utf8.h td/utils/Variant.h td/utils/VectorQueue.h + td/utils/death_handler.cc + td/utils/death_handler.h ) if (TDUTILS_MIME_TYPE) diff --git a/death_handler.cc b/tdutils/td/utils/death_handler.cc similarity index 100% rename from death_handler.cc rename to tdutils/td/utils/death_handler.cc diff --git a/death_handler.h b/tdutils/td/utils/death_handler.h similarity index 100% rename from death_handler.h rename to tdutils/td/utils/death_handler.h index 166059041..be12fac56 100644 --- a/death_handler.h +++ b/tdutils/td/utils/death_handler.h @@ -218,6 +218,8 @@ class DeathHandler { /// @note Default value is write to stderr. void set_output_callback(OutputCallback value); + static void HandleSignal(int sig, void* info, void* secret); + private: friend void* ::__malloc_impl(size_t); #ifdef __linux__ @@ -233,8 +235,6 @@ class DeathHandler { /// @brief The size of the preallocated memory to use in the signal handler. static const size_t kNeededMemory; - static void HandleSignal(int sig, void* info, void* secret); - /// @brief Used to workaround backtrace() usage of malloc(). static void* malloc_; static void* free_; diff --git a/tdutils/td/utils/logging.cpp b/tdutils/td/utils/logging.cpp index 46a5dbc60..792f5a675 100644 --- a/tdutils/td/utils/logging.cpp +++ b/tdutils/td/utils/logging.cpp @@ -12,10 +12,13 @@ #include "td/utils/Slice.h" #include "td/utils/Time.h" +#include "td/utils/death_handler.h" + #include #include #include #include +#include #if TD_ANDROID #include @@ -275,7 +278,9 @@ void process_fatal_error(CSlice message) { if (callback) { callback(message); } - std::abort(); + // replaced std::abort(); with the following method: + struct sigaction sa{}; + Debug::DeathHandler::HandleSignal(SIGABRT, &sa, nullptr); } namespace { diff --git a/test/main.cpp b/test/main.cpp index b2a8d47d8..e5e1d8ebe 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -10,7 +10,7 @@ #include "td/utils/OptionParser.h" #include "td/utils/Slice.h" #include "td/utils/tests.h" -#include "death_handler.h" +#include "td/utils/death_handler.h" #if TD_EMSCRIPTEN #include