aboutsummaryrefslogtreecommitdiffstats
path: root/main/mariadb/0001-Revert-MDEV-9127-Crash-reporter-often-fails-to-show-.patch
blob: 935bb81d4da040f7ff7e0edfac64400569f041f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
From dfa91fac7ecddd8b2c4c6459cc69396f5ec7e0a5 Mon Sep 17 00:00:00 2001
From: Carlo Landmeter <clandmeter@gmail.com>
Date: Tue, 9 Aug 2016 21:48:38 +0200
Subject: [PATCH] Revert "[MDEV-9127] Crash reporter often fails to show the
 query that crashed"

This reverts commit 7d4a7d8c5861e6587176052ea71c30ab12a49084.
---
 include/my_stacktrace.h |  2 +-
 mysys/stacktrace.c      | 30 ++++--------------------------
 sql/signal_handler.cc   | 23 +----------------------
 3 files changed, 6 insertions(+), 49 deletions(-)

diff --git a/include/my_stacktrace.h b/include/my_stacktrace.h
index fad6e53..fb2525e 100644
--- a/include/my_stacktrace.h
+++ b/include/my_stacktrace.h
@@ -45,7 +45,7 @@ C_MODE_START
 #if defined(HAVE_STACKTRACE) || defined(HAVE_BACKTRACE)
 void my_init_stacktrace();
 void my_print_stacktrace(uchar* stack_bottom, ulong thread_stack);
-int my_safe_print_str(const char* val, int max_len);
+void my_safe_print_str(const char* val, int max_len);
 void my_write_core(int sig);
 #if BACKTRACE_DEMANGLE
 char *my_demangle(const char *mangled_name, int *status);
diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c
index 3956592..4cc767f 100644
--- a/mysys/stacktrace.c
+++ b/mysys/stacktrace.c
@@ -129,32 +129,13 @@ static int safe_print_str(const char *addr, int max_len)
 
 #endif
 
-/*
-  Attempt to print a char * pointer as a string.
-
-  SYNOPSIS
-    Prints either until the end of string ('\0'), or max_len characters have
-    been printed.
-
-  RETURN VALUE
-    0  Pointer was within the heap address space.
-       The string was printed fully, or until the end of the heap address space.
-    1  Pointer is outside the heap address space. Printed as invalid.
-
-  NOTE
-    On some systems, we can have valid pointers outside the heap address space.
-    This is through the use of mmap inside malloc calls. When this function
-    returns 1, it does not mean 100% that the pointer is corrupted.
-*/
-
-int my_safe_print_str(const char* val, int max_len)
+void my_safe_print_str(const char* val, int max_len)
 {
   char *heap_end;
 
 #ifdef __linux__
-  // Try and make use of /proc filesystem to safely print memory contents.
   if (!safe_print_str(val, max_len))
-    return 0;
+    return;
 #endif
 
   heap_end= (char*) sbrk(0);
@@ -162,14 +143,12 @@ int my_safe_print_str(const char* val, int max_len)
   if (!PTR_SANE(val))
   {
     my_safe_printf_stderr("%s", "is an invalid pointer");
-    return 1;
+    return;
   }
 
   for (; max_len && PTR_SANE(val) && *val; --max_len)
     my_write_stderr((val++), 1);
   my_safe_printf_stderr("%s", "\n");
-
-  return 0;
 }
 
 #if defined(HAVE_PRINTSTACK)
@@ -748,7 +727,7 @@ void my_write_core(int unused)
 }
 
 
-int my_safe_print_str(const char *val, int len)
+void my_safe_print_str(const char *val, int len)
 {
   __try
   {
@@ -758,7 +737,6 @@ int my_safe_print_str(const char *val, int len)
   {
     my_safe_printf_stderr("%s", "is an invalid string pointer");
   }
-  return 0;
 }
 #endif /*__WIN__*/
 
diff --git a/sql/signal_handler.cc b/sql/signal_handler.cc
index 9dd3e53..9077b24 100644
--- a/sql/signal_handler.cc
+++ b/sql/signal_handler.cc
@@ -65,12 +65,6 @@ 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)
   {
@@ -207,12 +201,7 @@ 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());
-    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_print_str(thd->query(), MY_MIN(65536U, thd->query_length()));
     my_safe_printf_stderr("\nConnection ID (thread ID): %lu\n",
                           (ulong) thd->thread_id);
     my_safe_printf_stderr("Status: %s\n\n", kreason);
@@ -276,16 +265,6 @@ 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)
   {
-- 
2.9.1