MySQL 9.1.0
Source Code Documentation
|
#include "my_config.h"
#include "sql/signal_handler.h"
#include <signal.h>
#include <sys/types.h>
#include <time.h>
#include <algorithm>
#include <atomic>
#include "lex_string.h"
#include "my_inttypes.h"
#include <unistd.h>
#include "my_macros.h"
#include "my_stacktrace.h"
#include "my_sys.h"
#include "my_time.h"
#include "sql/mysqld.h"
#include "sql/sql_class.h"
#include "sql/sql_const.h"
Macros | |
#define | SIGNAL_FMT "signal %d" |
Functions | |
static void | print_extra_signal_information (int sig, siginfo_t *info) |
static void | print_fatal_signal (int sig, siginfo_t *info) |
This function will try to dump relevant debugging information to stderr. More... | |
void | handle_fatal_signal (int sig, siginfo_t *info, void *ucontext) |
Handler for fatal signals. More... | |
void | my_server_abort () |
This is a wrapper around abort() which ensures that abort() will be called exactly once, as calling it more than once might cause following problems: When original abort() is called there is a signal processing triggered, but only the first abort() causes the signal handler to be called, all other abort()s called by the other threads will cause immediate exit() call, which will also terminate the first abort() processing within the signal handler, aborting stacktrace printing, core writeout or any other processing. More... | |
Variables | |
static std::atomic< bool > | s_handler_being_processed {false} |
This is used to check if the signal handler is not called again while already handling the previous signal, as may happen when either another thread triggers it, or a bug in handling causes abort again. More... | |
static std::atomic< bool > | s_fatal_info_printed {false} |
Used to remember if the fatal info was already printed. More... | |
std::atomic< my_signal_handler_callback_t > | g_fatal_callback |
#define SIGNAL_FMT "signal %d" |
void handle_fatal_signal | ( | int | sig, |
siginfo_t * | info, | ||
void * | ucontext | ||
) |
Handler for fatal signals.
Fatal events (seg.fault, bus error etc.) will trigger this signal handler. The handler will try to dump relevant debugging information to stderr and dump a core image.
Signal handlers can only use a set of 'safe' system calls and library functions.
signal()
function: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/signal?view=msvc-160sig | Signal number |
info | Misc. information about the signal, see man sigaction(2). |
ucontext | Pointer to a ucontext_t structure. "Commonly, the handler function doesn't make any use of the third argument." |
void my_server_abort | ( | ) |
This is a wrapper around abort() which ensures that abort() will be called exactly once, as calling it more than once might cause following problems: When original abort() is called there is a signal processing triggered, but only the first abort() causes the signal handler to be called, all other abort()s called by the other threads will cause immediate exit() call, which will also terminate the first abort() processing within the signal handler, aborting stacktrace printing, core writeout or any other processing.
|
static |
|
static |
This function will try to dump relevant debugging information to stderr.
It may be called as part of the signal handler. This fact limits library calls that we can perform and much more,
sig | Signal number |
info | Misc. information about the signal, see man sigaction(2). |
std::atomic<my_signal_handler_callback_t> g_fatal_callback |
|
static |
Used to remember if the fatal info was already printed.
The info can be printed from user threads, but in the fatal signal handler we want to print it if and only if the info was not yet printed. User threads after printing the info will call abort which will call the handler.
|
static |
This is used to check if the signal handler is not called again while already handling the previous signal, as may happen when either another thread triggers it, or a bug in handling causes abort again.