diff options
author | Sergei Golubchik <serg@mariadb.org> | 2016-07-13 12:09:59 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2016-07-13 12:09:59 +0200 |
commit | 326a8dcd875b76faf85626942eb0e6ee76db304e (patch) | |
tree | c0d5a91cd2315dd2ce8d06a16c62778c78ca6f0f /sql/signal_handler.cc | |
parent | 64583629aded09f74d6d14178475fe6b2c849c00 (diff) | |
parent | c6fdb92ca829fed893d9e7324e80b1450de16087 (diff) | |
download | mariadb-git-326a8dcd875b76faf85626942eb0e6ee76db304e.tar.gz |
Merge branch '10.0' into 10.1
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 9077b24416b..9dd3e532d1e 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) { |