1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

Bug#31745 - crash handler does not work on Windows

- Replace per-thread signal()'s with  SetUnhandledExceptionFilter(). 
  The only remaining signal() is for SIGABRT (default abort()
  handler in VS2005 is broken, i.e removes user exception filter)
- remove MessageBox()'es  from error handling code
- Windows port for print_stacktrace() and write_core() 
- Cleanup, removed some unused functions


sql/CMakeLists.txt:
  Implement stack tracing on and generating crash dumps on Windows
sql/mysqld.cc:
  Correct signal handling on Windows. 
  - For console events, like CTRL-C use SetConsoleCtrlHandler
  - For exceptions like access violation, use SetUnhandledExceptionFilter
  - For SIGABRT generate exception via __debugbreak() intrinsic
    if built with VS2005 and later , since default SIGABRT handler 
    replaces unhandled exception filter specified by user
  - make provisions to debug exception filter, as it is not trivial 
  (should be compiled with /DDEBUG_UNHANDLED_EXCEPTION_FILTER)
sql/sql_parse.cc:
  Remove message box from windows signal handler.
  The only thread specific handler left is for SIGABRT,
  which is broken on VS2005 and later (user specified unhandled exception 
  filter gets overwritten)
sql/stacktrace.c:
  Stack tracing and generating crash dumps on Windows
sql/stacktrace.h:
  Implement print_stacktrace and write_core on Windows
This commit is contained in:
unknown
2008-02-19 12:37:39 +01:00
parent 32f5920676
commit 721d24124f
5 changed files with 469 additions and 75 deletions

View File

@ -98,22 +98,7 @@ static bool do_command(THD *thd);
#endif // EMBEDDED_LIBRARY
#ifdef __WIN__
static void test_signal(int sig_ptr)
{
#if !defined( DBUG_OFF)
MessageBox(NULL,"Test signal","DBUG",MB_OK);
#endif
#if defined(OS2)
fprintf(stderr, "Test signal %d\n", sig_ptr);
fflush(stderr);
#endif
}
static void init_signals(void)
{
int signals[7] = {SIGINT,SIGILL,SIGFPE,SIGSEGV,SIGTERM,SIGBREAK,SIGABRT } ;
for (int i=0 ; i < 7 ; i++)
signal( signals[i], test_signal) ;
}
extern void win_install_sigabrt_handler(void);
#endif
static void unlock_locked_tables(THD *thd)
@ -1124,7 +1109,7 @@ pthread_handler_t handle_one_connection(void *arg)
/* now that we've called my_thread_init(), it is safe to call DBUG_* */
#if defined(__WIN__)
init_signals();
win_install_sigabrt_handler();
#elif !defined(OS2) && !defined(__NETWARE__)
sigset_t set;
VOID(sigemptyset(&set)); // Get mask in use