2464
extern "C" sig_handler handle_segfault(int sig)
2470
Strictly speaking, one needs a mutex here
2471
but since we have got SIGSEGV already, things are a mess
2472
so not having the mutex is not as bad as possibly using a buggy
2473
mutex - so we keep things simple
2477
fprintf(stderr, "Fatal " SIGNAL_FMT " while backtracing\n", sig);
2483
curr_time= my_time(0);
2484
localtime_r(&curr_time, &tm);
2487
%02d%02d%02d %2d:%02d:%02d - mysqld got " SIGNAL_FMT " ;\n\
2488
This could be because you hit a bug. It is also possible that this binary\n\
2489
or one of the libraries it was linked against is corrupt, improperly built,\n\
2490
or misconfigured. This error can also be caused by malfunctioning hardware.\n",
2491
tm.tm_year % 100, tm.tm_mon+1, tm.tm_mday,
2492
tm.tm_hour, tm.tm_min, tm.tm_sec,
2495
We will try our best to scrape up some info that will hopefully help diagnose\n\
2496
the problem, but since we have already crashed, something is definitely wrong\n\
2497
and this may fail.\n\n");
2498
fprintf(stderr, "key_buffer_size=%lu\n",
2499
(ulong) dflt_key_cache->key_cache_mem_size);
2500
fprintf(stderr, "read_buffer_size=%ld\n", (long) global_system_variables.read_buff_size);
2501
fprintf(stderr, "max_used_connections=%lu\n", max_used_connections);
2502
fprintf(stderr, "max_threads=%u\n", thread_scheduler.max_threads);
2503
fprintf(stderr, "threads_connected=%u\n", thread_count);
2504
fprintf(stderr, "It is possible that mysqld could use up to \n\
2505
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = %lu K\n\
2506
bytes of memory\n", ((ulong) dflt_key_cache->key_cache_mem_size +
2507
(global_system_variables.read_buff_size +
2508
global_system_variables.sortbuff_size) *
2509
thread_scheduler.max_threads +
2510
max_connections * sizeof(THD)) / 1024);
2511
fprintf(stderr, "Hope that's ok; if not, decrease some variables in the equation.\n\n");
2513
#if defined(HAVE_LINUXTHREADS)
2514
if (sizeof(char*) == 4 && thread_count > UNSAFE_DEFAULT_LINUX_THREADS)
2517
You seem to be running 32-bit Linux and have %d concurrent connections.\n\
2518
If you have not changed STACK_SIZE in LinuxThreads and built the binary \n\
2519
yourself, LinuxThreads is quite likely to steal a part of the global heap for\n\
2520
the thread stack. Please read http://dev.mysql.com/doc/mysql/en/linux.html\n\n",
2523
#endif /* HAVE_LINUXTHREADS */
2525
#ifdef HAVE_STACKTRACE
2526
THD *thd=current_thd;
2528
if (!(test_flags & TEST_NO_STACKTRACE))
2530
fprintf(stderr, "thd: 0x%lx\n",(long) thd);
2531
fprintf(stderr, "Attempting backtrace. You can use the following "
2532
"information to find out\nwhere mysqld died. If "
2533
"you see no messages after this, something went\n"
2534
"terribly wrong...\n");
2535
my_print_stacktrace(thd ? (uchar*) thd->thread_stack : NULL,
2536
my_thread_stack_size);
2540
const char *kreason= "UNKNOWN";
2541
switch (thd->killed) {
2542
case THD::NOT_KILLED:
2543
kreason= "NOT_KILLED";
2545
case THD::KILL_BAD_DATA:
2546
kreason= "KILL_BAD_DATA";
2548
case THD::KILL_CONNECTION:
2549
kreason= "KILL_CONNECTION";
2551
case THD::KILL_QUERY:
2552
kreason= "KILL_QUERY";
2554
case THD::KILLED_NO_VALUE:
2555
kreason= "KILLED_NO_VALUE";
2558
fprintf(stderr, "Trying to get some variables.\n\
2559
Some pointers may be invalid and cause the dump to abort...\n");
2560
my_safe_print_str("thd->query", thd->query(), 1024);
2561
fprintf(stderr, "thd->thread_id=%lu\n", (ulong) thd->thread_id);
2562
fprintf(stderr, "thd->killed=%s\n", kreason);
2565
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains\n\
2566
information that should help you find out what is causing the crash.\n");
2568
#endif /* HAVE_STACKTRACE */
2570
#ifdef HAVE_INITGROUPS
2571
if (calling_initgroups)
2572
fprintf(stderr, "\n\
2573
This crash occured while the server was calling initgroups(). This is\n\
2574
often due to the use of a mysqld that is statically linked against glibc\n\
2575
and configured to use LDAP in /etc/nsswitch.conf. You will need to either\n\
2576
upgrade to a version of glibc that does not have this problem (2.3.4 or\n\
2577
later when used with nscd), disable LDAP in your nsswitch.conf, or use a\n\
2578
mysqld that is not statically linked.\n");
2582
if (thd_lib_detected == THD_LIB_LT && !getenv("LD_ASSUME_KERNEL"))
2584
You are running a statically-linked LinuxThreads binary on an NPTL system.\n\
2585
This can result in crashes on some distributions due to LT/NPTL conflicts.\n\
2586
You should either build a dynamically-linked binary, or force LinuxThreads\n\
2587
to be used with the LD_ASSUME_KERNEL environment variable. Please consult\n\
2588
the documentation for your distribution on how to do that.\n");
2591
if (locked_in_memory)
2593
fprintf(stderr, "\n\
2594
The \"--memlock\" argument, which was enabled, uses system calls that are\n\
2595
unreliable and unstable on some operating systems and operating-system\n\
2596
versions (notably, some versions of Linux). This crash could be due to use\n\
2597
of those buggy OS calls. You should consider whether you really need the\n\
2598
\"--memlock\" parameter and/or consult the OS distributer about \"mlockall\"\n\
2602
#ifdef HAVE_WRITE_CORE
2603
if (test_flags & TEST_CORE_ON_SIGNAL)
2605
fprintf(stderr, "Writing a core file\n");
2612
/* On Windows, do not terminate, but pass control to exception filter */
2617
2485
#if !defined(__WIN__) && !defined(__NETWARE__)
2618
2486
#ifndef SA_RESETHAND
2619
2487
#define SA_RESETHAND 0
6860
6751
&global_system_variables.max_length_for_sort_data,
6861
6752
&max_system_variables.max_length_for_sort_data, 0, GET_ULONG,
6862
6753
REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0},
6754
{"max_long_data_size", OPT_MAX_LONG_DATA_SIZE,
6755
"The maximum size of prepared statement parameter which can be provided "
6756
"through mysql_send_long_data() API call. "
6757
"Deprecated option; use max_allowed_packet instead.",
6758
&max_long_data_size,
6759
&max_long_data_size, 0, GET_ULONG,
6760
REQUIRED_ARG, 1024*1024L, 1024, UINT_MAX32, MALLOC_OVERHEAD, 1, 0},
6863
6761
{"max_prepared_stmt_count", OPT_MAX_PREPARED_STMT_COUNT,
6864
6762
"Maximum number of prepared statements in the server.",
6865
6763
&max_prepared_stmt_count, &max_prepared_stmt_count,