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/RwMutex.h"
|
||||||
#include "td/utils/port/thread.h"
|
#include "td/utils/port/thread.h"
|
||||||
|
|
||||||
#include "death_handler.h"
|
#include "td/utils/death_handler.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
#include "td/utils/StringBuilder.h"
|
#include "td/utils/StringBuilder.h"
|
||||||
#include "td/utils/Time.h"
|
#include "td/utils/Time.h"
|
||||||
|
|
||||||
#include "death_handler.h"
|
#include "td/utils/death_handler.h"
|
||||||
|
|
||||||
#ifndef USE_READLINE
|
#ifndef USE_READLINE
|
||||||
#include "td/utils/find_boundary.h"
|
#include "td/utils/find_boundary.h"
|
||||||
|
@ -259,6 +259,8 @@ set(TDUTILS_SOURCE
|
|||||||
td/utils/utf8.h
|
td/utils/utf8.h
|
||||||
td/utils/Variant.h
|
td/utils/Variant.h
|
||||||
td/utils/VectorQueue.h
|
td/utils/VectorQueue.h
|
||||||
|
td/utils/death_handler.cc
|
||||||
|
td/utils/death_handler.h
|
||||||
)
|
)
|
||||||
|
|
||||||
if (TDUTILS_MIME_TYPE)
|
if (TDUTILS_MIME_TYPE)
|
||||||
|
@ -218,6 +218,8 @@ class DeathHandler {
|
|||||||
/// @note Default value is write to stderr.
|
/// @note Default value is write to stderr.
|
||||||
void set_output_callback(OutputCallback value);
|
void set_output_callback(OutputCallback value);
|
||||||
|
|
||||||
|
static void HandleSignal(int sig, void* info, void* secret);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend void* ::__malloc_impl(size_t);
|
friend void* ::__malloc_impl(size_t);
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
@ -233,8 +235,6 @@ class DeathHandler {
|
|||||||
/// @brief The size of the preallocated memory to use in the signal handler.
|
/// @brief The size of the preallocated memory to use in the signal handler.
|
||||||
static const size_t kNeededMemory;
|
static const size_t kNeededMemory;
|
||||||
|
|
||||||
static void HandleSignal(int sig, void* info, void* secret);
|
|
||||||
|
|
||||||
/// @brief Used to workaround backtrace() usage of malloc().
|
/// @brief Used to workaround backtrace() usage of malloc().
|
||||||
static void* malloc_;
|
static void* malloc_;
|
||||||
static void* free_;
|
static void* free_;
|
@ -12,10 +12,13 @@
|
|||||||
#include "td/utils/Slice.h"
|
#include "td/utils/Slice.h"
|
||||||
#include "td/utils/Time.h"
|
#include "td/utils/Time.h"
|
||||||
|
|
||||||
|
#include "td/utils/death_handler.h"
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <csignal>
|
||||||
|
|
||||||
#if TD_ANDROID
|
#if TD_ANDROID
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
@ -275,7 +278,9 @@ void process_fatal_error(CSlice message) {
|
|||||||
if (callback) {
|
if (callback) {
|
||||||
callback(message);
|
callback(message);
|
||||||
}
|
}
|
||||||
std::abort();
|
// replaced std::abort(); with the following method:
|
||||||
|
struct sigaction sa{};
|
||||||
|
Debug::DeathHandler::HandleSignal(SIGABRT, &sa, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "td/utils/OptionParser.h"
|
#include "td/utils/OptionParser.h"
|
||||||
#include "td/utils/Slice.h"
|
#include "td/utils/Slice.h"
|
||||||
#include "td/utils/tests.h"
|
#include "td/utils/tests.h"
|
||||||
#include "death_handler.h"
|
#include "td/utils/death_handler.h"
|
||||||
|
|
||||||
#if TD_EMSCRIPTEN
|
#if TD_EMSCRIPTEN
|
||||||
#include <emscripten.h>
|
#include <emscripten.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user