From a6ec1f09b09f03652d6ab00b2a6632979825ffa3 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 Aug 2000 06:05:12 +0300 Subject: [PATCH] --core-file ; To get a core on SIGSEGV when using Linuxthreads Docs/manual.texi: Documentation for --core-file sql/mysql_priv.h: --core-file sql/mysqld.cc: --core-file --- Docs/manual.texi | 21 ++++++++++++++++++--- sql/mysql_priv.h | 2 +- sql/mysqld.cc | 43 +++++++++++++++++++++++++++++++++++++------ 3 files changed, 56 insertions(+), 10 deletions(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index a409e442b68..4bd5e9c80d3 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -5896,9 +5896,9 @@ of function} warnings. These may be ignored. @node Linux, Alpha-DEC-Unix, SunOS, Source install system issues @subsection Linux notes (all Linux versions) -@strong{MySQL} uses LinuxThreads on Linux. If you are using an old Linux -version that doesn't have @code{glibc2}, you must install LinuxThreads before -trying to compile +@strong{MySQL} uses LinuxThreads on Linux. If you are using an old +Linux version that doesn't have @code{glibc2}, you must install +LinuxThreads before trying to compile @strong{MySQL}. @uref{http://www.mysql.com/Downloads/Linux} Note that @code{glibc} versions before and including 2.1.1 has a fatal @@ -5969,6 +5969,11 @@ If you see a dead @code{mysqld} daemon process with @code{ps}, this usually means that you have found a bug in @strong{MySQL} or you have got a corrupted table. @xref{Crashing}. +If you want to get a core dump on Linux if mysqld dies with a SIGSEGV +signal, you can start mysqld with the @code{--core-file} option. Note +that you also probably need to raise the @code{core file size} with +@code{ulimit}! + If you are using LinuxThreads and @code{mysqladmin shutdown} doesn't work, you must upgrade to LinuxThreads 0.7.1 or newer. @@ -6165,6 +6170,10 @@ until you have installed @code{glibc} 2.0.7-19 from source! You can check which version of @code{glibc} you have with @code{rpm -q glibc}. +Another reason for the above error is if you try to use more threads +than your Linux kernel is configured for. In this case you should rise +the limits in @file{include/linux/tasks.h} and recompile your kernel! + @node Linux-SPARC, Linux-Alpha, Linux-RedHat51, Linux @subsubsection Linux-SPARC notes @@ -35686,6 +35695,9 @@ though, so 3.23 is not released as a stable version yet. @appendixsubsec Changes in release 3.23.23 @itemize @bullet @item +Added option @code{--core-file} to @code{mysqld} to get a core file on +Linux if mysqld dies on the SIGSEGV signal +@item @strong{MySQL} client 'mysql' now starts with option --no-named-commands (-g) by default. This option can be disabled with --enable-named-commands (-G). This may cause incompatibility problems in some cases, for example @@ -40324,6 +40336,9 @@ old threads. You can avoid this problem by starting @code{mysqld} with @code{-O thread_cache_size= 'max_connections +1'}. In most cases just using @code{-O thread_cache_size= 5'} will help a lot! +If you want to get a core dump on Linux if mysqld dies with a SIGSEGV signal, +you can start mysqld with the @code{--core-file} option. + If you are using gdb 4.17.x or above on Linux, you should install a @file{.gdb} file, with the following information, in your current directory: diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 7e3186defd3..7e372a7ffd1 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -127,7 +127,7 @@ void sql_element_free(void *ptr); #define TEST_NO_THREADS 32 /* For debugging under Linux */ #define TEST_READCHECK 64 /* Force use of readcheck */ #define TEST_NO_EXTRA 128 -#define TEST_KILL_ON_DEBUG 256 /* Kill server */ +#define TEST_CORE_ON_SIGNAL 256 /* Give core if signal */ /* options for select set by the yacc parser */ #define SELECT_DISTINCT 1 diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 37b03ef4a67..8ea12f68da8 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1003,6 +1003,20 @@ static void init_signals(void) } #else +#ifdef HAVE_LINUXTHREADS + +/* Produce a core for the thread */ + +static sig_handler write_core(int sig) +{ + fprintf(stderr,"Got signal %s in thread %d\n",sys_siglist[sig],getpid()); + signal(sig, SIG_DFL); + if (fork() != 0) exit(1); // Abort main program + // Core will be written at exit +} +#endif + + static void init_signals(void) { sigset_t set; @@ -1012,6 +1026,16 @@ static void init_signals(void) sigset(THR_KILL_SIGNAL,end_thread_signal); sigset(THR_SERVER_ALARM,print_signal_warning); // Should never be called! +#ifdef HAVE_LINUXTHREADS + if (test_flags & TEST_CORE_ON_SIGNAL) + { + struct sigaction sa; sa.sa_flags = 0; + sigemptyset(&sa.sa_mask); + sigprocmask(SIG_SETMASK,&sa.sa_mask,NULL); + sa.sa_handler=write_core; + sigaction(SIGSEGV, &sa, NULL); + } +#endif (void) sigemptyset(&set); #ifdef THREAD_SPECIFIC_SIGPIPE sigset(SIGPIPE,abort_thread); @@ -2134,7 +2158,7 @@ enum options {OPT_ISAM_LOG=256,OPT_SKIP_NEW,OPT_SKIP_GRANT, OPT_MASTER_PORT, OPT_MASTER_INFO_FILE, OPT_MASTER_CONNECT_RETRY, OPT_SQL_BIN_UPDATE_SAME, OPT_REPLICATE_DO_DB, OPT_REPLICATE_IGNORE_DB, OPT_LOG_SLAVE_UPDATES, - OPT_BINLOG_DO_DB, OPT_BINLOG_IGNORE_DB}; + OPT_BINLOG_DO_DB, OPT_BINLOG_IGNORE_DB, OPT_WANT_CORE}; static struct option long_options[] = { @@ -2156,6 +2180,7 @@ static struct option long_options[] = #ifdef __WIN__ {"console", no_argument, 0, OPT_CONSOLE}, #endif + {"core-file", no_argument, 0, OPT_WANT_CORE}, {"chroot", required_argument,0, 'r'}, {"character-sets-dir",required_argument,0, OPT_CHARSETS_DIR}, {"datadir", required_argument, 0, 'h'}, @@ -2188,8 +2213,10 @@ static struct option long_options[] = {"master-connect-retry", required_argument, 0, (int) OPT_MASTER_CONNECT_RETRY}, {"master-info-file", required_argument, 0, (int) OPT_MASTER_INFO_FILE}, {"new", no_argument, 0, 'n'}, - {"old-protocol", no_argument, 0, 'o'}, + {"old-protocol", no_argument, 0, 'o'}, +#ifndef DBUG_OFF {"one-thread", no_argument, 0, OPT_ONE_THREAD}, +#endif {"pid-file", required_argument, 0, (int) OPT_PID_FILE}, {"port", required_argument, 0, 'P'}, {"replicate-do-db", required_argument, 0, OPT_REPLICATE_DO_DB}, @@ -2432,6 +2459,7 @@ static void usage(void) --character-sets-dir=...\n\ Directory where character sets are\n\ --chroot=path Chroot mysqld daemon during startup\n\ + --core-file Write core on errors\n\ -h, --datadir=path Path to the database root"); #ifndef DBUG_OFF printf("\ @@ -2465,9 +2493,11 @@ static void usage(void) --pid-file=path Pid file used by safe_mysqld\n\ -P, --port=... Port number to use for connection\n\ -n, --new Use very new possible 'unsafe' functions\n\ - -o, --old-protocol Use the old (3.20) protocol\n\ + -o, --old-protocol Use the old (3.20) protocol\n"); +#ifndef DBUG_OFF + puts("\ --one-thread Only use one thread (for debugging under Linux)\n"); - /* We have to break the string here because of VC++ limits */ +#endif puts("\ -O, --set-variable var=option\n\ Give a variable an value. --help lists variables\n\ @@ -2729,8 +2759,6 @@ static void get_options(int argc,char **argv) binlog_do_db.push_back(db); break; } - - case (int) OPT_SQL_BIN_UPDATE_SAME: opt_sql_bin_update = 1; break; @@ -2785,6 +2813,9 @@ static void get_options(int argc,char **argv) case (int) OPT_ONE_THREAD: test_flags |= TEST_NO_THREADS; break; + case (int) OPT_WANT_CORE: + test_flags |= TEST_CORE_ON_SIGNAL; + break; case (int) OPT_BIND_ADDRESS: if (optarg && isdigit(optarg[0])) {