MySQL 8.0.40
Source Code Documentation
signal_handler.cc File Reference
#include "my_config.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

void print_fatal_signal (int sig)
 This function will try to dump relevant debugging information to stderr and dump a core image. More...
 
void handle_fatal_signal (int sig)
 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...
 

Macro Definition Documentation

◆ SIGNAL_FMT

#define SIGNAL_FMT   "signal %d"

Function Documentation

◆ handle_fatal_signal()

void handle_fatal_signal ( int  sig)

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.

Parameters
sigSignal number

◆ my_server_abort()

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.

◆ print_fatal_signal()

void print_fatal_signal ( int  sig)

This function will try to dump relevant debugging information to stderr and dump a core image.

It may be called as part of the signal handler. This fact limits library calls that we can perform and much more,

See also
handle_fatal_signal
Parameters
sigSignal number

Variable Documentation

◆ s_fatal_info_printed

std::atomic<bool> s_fatal_info_printed {false}
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.

◆ s_handler_being_processed

std::atomic<bool> s_handler_being_processed {false}
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.