Replaced checks abort() with death handlers
This commit is contained in:
parent
5f188a293a
commit
2ee1930f65
@ -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 <algorithm>
|
||||
#include <atomic>
|
||||
|
@ -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"
|
||||
|
@ -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)
|
||||
|
@ -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_;
|
@ -12,10 +12,13 @@
|
||||
#include "td/utils/Slice.h"
|
||||
#include "td/utils/Time.h"
|
||||
|
||||
#include "td/utils/death_handler.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdlib>
|
||||
#include <limits>
|
||||
#include <mutex>
|
||||
#include <csignal>
|
||||
|
||||
#if TD_ANDROID
|
||||
#include <android/log.h>
|
||||
@ -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 {
|
||||
|
@ -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 <emscripten.h>
|
||||
|
Loading…
Reference in New Issue
Block a user