85
static void write_core(int sig)
90
For GCOV build, crashing will prevent the writing of code coverage
91
information from this process, causing gcov output to be incomplete.
92
So we force the writing of coverage information here before terminating.
94
extern void __gcov_flush(void);
97
pthread_kill(pthread_self(), sig);
98
#if defined(P_MYID) && !defined(SCO)
99
/* On Solaris, the above kill is not enough */
100
sigsend(P_PID,P_MYID,sig);
104
#define BACKTRACE_STACK_SIZE 50
79
105
void drizzled_handle_segfault(int sig)
120
146
fprintf(stderr, "max_used_connections=%"PRIu64"\n", current_global_counters.max_used_connections);
121
147
fprintf(stderr, "connection_count=%u\n", uint32_t(connection_count));
122
148
fprintf(stderr, _("It is possible that drizzled could use up to \n"
123
"key_buffer_size + (read_buffer_size + "
124
"sort_buffer_size)*thread_count\n"
149
"(read_buffer_size + sort_buffer_size)*thread_count\n"
125
150
"bytes of memory\n"
126
151
"Hope that's ok; if not, decrease some variables in the "
127
152
"equation.\n\n"));
129
#ifdef HAVE_STACKTRACE
130
Session *session= current_session;
132
if (! (test_flags.test(TEST_NO_STACKTRACE)))
134
fprintf(stderr,"session: 0x%lx\n",(long) session);
135
fprintf(stderr,_("Attempting backtrace. You can use the following "
136
"information to find out\n"
137
"where drizzled died. If you see no messages after this, "
139
"terribly wrong...\n"));
140
print_stacktrace(session ? (unsigned char*) session->thread_stack : (unsigned char*) 0,
141
my_thread_stack_size);
145
const char *kreason= "UNKNOWN";
146
switch (session->killed) {
147
case Session::NOT_KILLED:
148
kreason= "NOT_KILLED";
150
case Session::KILL_BAD_DATA:
151
kreason= "KILL_BAD_DATA";
153
case Session::KILL_CONNECTION:
154
kreason= "KILL_CONNECTION";
156
case Session::KILL_QUERY:
157
kreason= "KILL_QUERY";
159
case Session::KILLED_NO_VALUE:
160
kreason= "KILLED_NO_VALUE";
155
#ifdef HAVE_BACKTRACE
157
void *array[BACKTRACE_STACK_SIZE];
161
size= backtrace(array, BACKTRACE_STACK_SIZE);
162
strings= backtrace_symbols(array, size);
164
std::cerr << "Number of stack frames obtained: " << size << std::endl;
166
for (size_t x= 1; x < size; x++)
169
char *function= (char *)malloc(sz);
173
for (char *j = strings[x]; *j; ++j)
178
else if (*j == '+') {
188
char *ret = abi::__cxa_demangle(begin, function, &sz, &status);
195
std::strncpy(function, begin, sz);
196
std::strncat(function, "()", sz);
197
function[sz-1] = NULL;
199
std::cerr << function << std::endl;
203
std::cerr << strings[x] << std::endl;
163
fprintf(stderr, _("Trying to get some variables.\n"
164
"Some pointers may be invalid and cause the "
165
"dump to abort...\n"));
166
safe_print_str("session->query", session->query, 1024);
167
fprintf(stderr, "session->thread_id=%"PRIu32"\n", (uint32_t) session->thread_id);
168
fprintf(stderr, "session->killed=%s\n", kreason);
171
#endif /* HAVE_STACKTRACE */
173
if (calling_initgroups)
174
fprintf(stderr, _("\nThis crash occurred while the server was calling "
175
"initgroups(). This is\n"
176
"often due to the use of a drizzled that is statically "
177
"linked against glibc\n"
178
"and configured to use LDAP in /etc/nsswitch.conf. "
179
"You will need to either\n"
180
"upgrade to a version of glibc that does not have this "
181
"problem (2.3.4 or\n"
182
"later when used with nscd), disable LDAP in your "
183
"nsswitch.conf, or use a\n"
184
"drizzled that is not statically linked.\n"));
186
if (internal::thd_lib_detected == THD_LIB_LT && !getenv("LD_ASSUME_KERNEL"))
188
_("\nYou are running a statically-linked LinuxThreads binary "
189
"on an NPTL system.\n"
190
"This can result in crashes on some distributions due "
191
"to LT/NPTL conflicts.\n"
192
"You should either build a dynamically-linked binary, or force "
194
"to be used with the LD_ASSUME_KERNEL environment variable. "
196
"the documentation for your distribution on how to do that.\n"));
198
#ifdef HAVE_WRITE_CORE
199
if (test_flags.test(TEST_CORE_ON_SIGNAL))
201
fprintf(stderr, _("Writing a core file\n"));
211
#endif // HAVE_BACKTRACE