summaryrefslogtreecommitdiff
path: root/client/mysqltest.c
diff options
context:
space:
mode:
authorDavi Arnaut <davi@mysql.com>2008-06-19 11:02:32 -0300
committerDavi Arnaut <davi@mysql.com>2008-06-19 11:02:32 -0300
commitfcaaee631792b51ce7ea12db1d5f5c2019d0fa3b (patch)
treea27f81ac24a83b96d235ee7489aefe3223a88867 /client/mysqltest.c
parentfb8f32d0774876f79f7e3d9aa714c0ecb67adaca (diff)
downloadmariadb-git-fcaaee631792b51ce7ea12db1d5f5c2019d0fa3b.tar.gz
Bug#37003 Tests sporadically crashes with embedded server
Another problem is that the backtrace facility wasn't being enabled for non-Linux targets even if the target OS has the backtrace functions. Also, the stacktrace functions inside mysqltest were being used without proper checks for their presence in the build. client/mysqltest.c: Only use stacktrace functions if they are available. configure.in: Check if the compiler defines __bss_start include/my_stacktrace.h: Enable stacktrace if system has backtrace functions. mysys/stacktrace.c: Use backtrace functions if the system supports it. sql/mysqld.cc: Only use stacktrace functions if they are available.
Diffstat (limited to 'client/mysqltest.c')
-rw-r--r--client/mysqltest.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 5cc0951cdf5..f5a5c05b236 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -48,6 +48,7 @@
#ifdef __WIN__
#include <direct.h>
#endif
+#include <signal.h>
#include <my_stacktrace.h>
#ifdef __WIN__
@@ -6847,12 +6848,12 @@ void mark_progress(struct st_command* command __attribute__((unused)),
}
+#ifdef HAVE_STACKTRACE
-static sig_handler dump_backtrace(int sig)
+static void dump_backtrace(void)
{
struct st_connection *conn= cur_con;
- fprintf(stderr, "mysqltest got " SIGNAL_FMT "\n", sig);
my_safe_print_str("read_command_buf", read_command_buf,
sizeof(read_command_buf));
if (conn)
@@ -6866,6 +6867,21 @@ static sig_handler dump_backtrace(int sig)
my_print_stacktrace(NULL, my_thread_stack_size);
}
+#else
+
+static void dump_backtrace(void)
+{
+ fputs("Backtrace not available.\n", stderr);
+}
+
+#endif
+
+static sig_handler signal_handler(int sig)
+{
+ fprintf(stderr, "mysqltest got " SIGNAL_FMT "\n", sig);
+ dump_backtrace();
+}
+
#ifdef __WIN__
LONG WINAPI exception_filter(EXCEPTION_POINTERS *exp)
@@ -6873,7 +6889,7 @@ LONG WINAPI exception_filter(EXCEPTION_POINTERS *exp)
__try
{
my_set_exception_pointers(exp);
- dump_backtrace(exp->ExceptionRecord->ExceptionCode);
+ signal_handler(exp->ExceptionRecord->ExceptionCode);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
@@ -6910,13 +6926,15 @@ static void init_signal_handling(void)
struct sigaction sa;
DBUG_ENTER("init_signal_handling");
+#ifdef HAVE_STACKTRACE
my_init_stacktrace();
+#endif
sa.sa_flags = SA_RESETHAND | SA_NODEFER;
sigemptyset(&sa.sa_mask);
sigprocmask(SIG_SETMASK, &sa.sa_mask, NULL);
- sa.sa_handler= dump_backtrace;
+ sa.sa_handler= signal_handler;
sigaction(SIGSEGV, &sa, NULL);
sigaction(SIGABRT, &sa, NULL);