diff options
author | Sergei Golubchik <serg@mariadb.org> | 2016-09-09 08:33:08 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2016-09-09 08:33:08 +0200 |
commit | 06b7fce9f24116080168b924d17f71b979fc3a14 (patch) | |
tree | 5ff9f5684bb118abbee5a9fd3b838d0841661287 /sql/signal_handler.cc | |
parent | 1f2ff25eba6c089b2698cd0dab96155ccbf2afd2 (diff) | |
parent | 8494039757a2f6353cc161e7824aab4fe2312d2a (diff) | |
download | mariadb-git-06b7fce9f24116080168b924d17f71b979fc3a14.tar.gz |
Merge branch '10.1' into 10.2
Diffstat (limited to 'sql/signal_handler.cc')
-rw-r--r-- | sql/signal_handler.cc | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/sql/signal_handler.cc b/sql/signal_handler.cc index ae49e65bb1d..f9478134ab4 100644 --- a/sql/signal_handler.cc +++ b/sql/signal_handler.cc @@ -65,6 +65,12 @@ extern "C" sig_handler handle_fatal_signal(int sig) #ifdef HAVE_STACKTRACE THD *thd; #endif + /* + This flag remembers if the query pointer was found invalid. + We will try and print the query at the end of the signal handler, in case + we're wrong. + */ + bool print_invalid_query_pointer= false; if (segfaulted) { @@ -201,7 +207,12 @@ extern "C" sig_handler handle_fatal_signal(int sig) "Some pointers may be invalid and cause the dump to abort.\n"); my_safe_printf_stderr("Query (%p): ", thd->query()); - my_safe_print_str(thd->query(), MY_MIN(65536U, thd->query_length())); + if (my_safe_print_str(thd->query(), MY_MIN(65536U, thd->query_length()))) + { + // Query was found invalid. We will try to print it at the end. + print_invalid_query_pointer= true; + } + my_safe_printf_stderr("\nConnection ID (thread ID): %lu\n", (ulong) thd->thread_id); my_safe_printf_stderr("Status: %s\n\n", kreason); @@ -265,6 +276,16 @@ extern "C" sig_handler handle_fatal_signal(int sig) "\"mlockall\" bugs.\n"); } + if (print_invalid_query_pointer) + { + my_safe_printf_stderr( + "\nWe think the query pointer is invalid, but we will try " + "to print it anyway. \n" + "Query: "); + my_write_stderr(thd->query(), MY_MIN(65536U, thd->query_length())); + my_safe_printf_stderr("\n\n"); + } + #ifdef HAVE_WRITE_CORE if (test_flags & TEST_CORE_ON_SIGNAL) { |