Commit d4991387 authored by Alexander Nozdrin's avatar Alexander Nozdrin

A patch for Bug#47474 (mysqld hits Dbug_violation_helper assert

when compiled with Sun Studio compiler).

The thing is that Sun Studio compiler calls destructor of stack
objects when pthread_exit() is called. That triggered an assertion
in DBUG_ENTER()/DBUG_RETURN() validation logic (if DBUG_ENTER() is
used in the beginning of function, all returns should be replaced
by DBUG_RETURN/DBUG_VOID_RETURN macros).

A fix is to explicitly use DBUG_LEAVE macro.
parent e6afad88
......@@ -9426,9 +9426,11 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
pthread_cond_signal(&COND_ndb_util_ready);
pthread_mutex_unlock(&LOCK_ndb_util_thread);
DBUG_PRINT("exit", ("ndb_util_thread"));
DBUG_LEAVE; // Must match DBUG_ENTER()
my_thread_end();
pthread_exit(0);
DBUG_RETURN(NULL);
return NULL; // Avoid compiler warnings
}
/*
......
......@@ -3663,9 +3663,11 @@ pthread_handler_t ndb_binlog_thread_func(void *arg)
ndb_binlog_thread_running= -1;
pthread_mutex_unlock(&injector_mutex);
pthread_cond_signal(&injector_cond);
DBUG_LEAVE; // Must match DBUG_ENTER()
my_thread_end();
pthread_exit(0);
DBUG_RETURN(NULL);
return NULL; // Avoid compiler warnings
}
lex_start(thd);
......@@ -4376,10 +4378,11 @@ pthread_handler_t ndb_binlog_thread_func(void *arg)
(void) pthread_cond_signal(&injector_cond);
DBUG_PRINT("exit", ("ndb_binlog_thread"));
my_thread_end();
DBUG_LEAVE; // Must match DBUG_ENTER()
my_thread_end();
pthread_exit(0);
DBUG_RETURN(NULL);
return NULL; // Avoid compiler warnings
}
bool
......
......@@ -1107,13 +1107,13 @@ void kill_mysql(void)
#if defined(__NETWARE__)
extern "C" void kill_server(int sig_ptr)
#define RETURN_FROM_KILL_SERVER DBUG_VOID_RETURN
#define RETURN_FROM_KILL_SERVER return
#elif !defined(__WIN__)
static void *kill_server(void *sig_ptr)
#define RETURN_FROM_KILL_SERVER DBUG_RETURN(0)
#define RETURN_FROM_KILL_SERVER return 0
#else
static void __cdecl kill_server(int sig_ptr)
#define RETURN_FROM_KILL_SERVER DBUG_VOID_RETURN
#define RETURN_FROM_KILL_SERVER return
#endif
{
DBUG_ENTER("kill_server");
......@@ -1121,7 +1121,10 @@ static void __cdecl kill_server(int sig_ptr)
int sig=(int) (long) sig_ptr; // This is passed a int
// if there is a signal during the kill in progress, ignore the other
if (kill_in_progress) // Safety
{
DBUG_LEAVE;
RETURN_FROM_KILL_SERVER;
}
kill_in_progress=TRUE;
abort_loop=1; // This should be set
if (sig != 0) // 0 is not a valid signal number
......@@ -1156,12 +1159,19 @@ static void __cdecl kill_server(int sig_ptr)
pthread_join(select_thread, NULL); // wait for main thread
#endif /* __NETWARE__ */
DBUG_LEAVE; // Must match DBUG_ENTER()
my_thread_end();
pthread_exit(0);
/* purecov: end */
#endif /* EMBEDDED_LIBRARY */
RETURN_FROM_KILL_SERVER; // Avoid compiler warnings
#else /* EMBEDDED_LIBRARY*/
DBUG_LEAVE;
RETURN_FROM_KILL_SERVER;
#endif /* EMBEDDED_LIBRARY */
}
......@@ -1935,8 +1945,9 @@ bool one_thread_per_connection_end(THD *thd, bool put_in_cache)
my_thread_end();
(void) pthread_cond_broadcast(&COND_thread_count);
DBUG_LEAVE; // Must match DBUG_ENTER()
pthread_exit(0);
DBUG_RETURN(0); // Impossible
return 0; // Avoid compiler warnings
}
......@@ -2756,7 +2767,9 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
DBUG_PRINT("quit",("signal_handler: calling my_thread_end()"));
my_thread_end();
signal_thread_in_use= 0;
DBUG_LEAVE; // Must match DBUG_ENTER()
pthread_exit(0); // Safety
return 0; // Avoid compiler warnings
}
switch (sig) {
case SIGTERM:
......
......@@ -638,9 +638,11 @@ pthread_handler_t handle_failsafe_rpl(void *arg)
if (recovery_captain)
mysql_close(recovery_captain);
delete thd;
DBUG_LEAVE; // Must match DBUG_ENTER()
my_thread_end();
pthread_exit(0);
DBUG_RETURN(0);
return 0; // Avoid compiler warnings
}
#endif
......
......@@ -2799,9 +2799,11 @@ log space");
pthread_cond_broadcast(&mi->stop_cond); // tell the world we are done
DBUG_EXECUTE_IF("simulate_slave_delay_at_terminate_bug38694", sleep(5););
pthread_mutex_unlock(&mi->run_lock);
DBUG_LEAVE; // Must match DBUG_ENTER()
my_thread_end();
pthread_exit(0);
DBUG_RETURN(0); // Can't return anything here
return 0; // Avoid compiler warnings
}
/*
......@@ -3157,10 +3159,11 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \
pthread_cond_broadcast(&rli->stop_cond);
DBUG_EXECUTE_IF("simulate_slave_delay_at_terminate_bug38694", sleep(5););
pthread_mutex_unlock(&rli->run_lock); // tell the world we are done
DBUG_LEAVE; // Must match DBUG_ENTER()
my_thread_end();
pthread_exit(0);
DBUG_RETURN(0); // Can't return anything here
return 0; // Avoid compiler warnings
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment