diff options
author | Stefan Metzmacher <metze@samba.org> | 2004-01-22 02:28:17 +0000 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2004-01-22 02:28:17 +0000 |
commit | da9372463775fa09d081307fb78b109b90e8175a (patch) | |
tree | f6bf9a4b9cf596e8e40b65954fc0be0cc5fe2709 | |
parent | 3c310c7aa23a3cb5ab5e16de442f66523d0d6dca (diff) | |
download | samba-da9372463775fa09d081307fb78b109b90e8175a.tar.gz samba-da9372463775fa09d081307fb78b109b90e8175a.tar.bz2 samba-da9372463775fa09d081307fb78b109b90e8175a.zip |
- move the vars used by the backtrace stuff into the #ifdef
- handle SIBABRT with a backtrace
metze
(This used to be commit e9f584143d5bbcbbdaaac2c231efd85c7bd5a922)
-rw-r--r-- | source4/smbd/process_thread.c | 65 |
1 files changed, 39 insertions, 26 deletions
diff --git a/source4/smbd/process_thread.c b/source4/smbd/process_thread.c index 9acd49916b..d83f48de9f 100644 --- a/source4/smbd/process_thread.c +++ b/source4/smbd/process_thread.c @@ -312,18 +312,21 @@ static int thread_rwlock_unlock(smb_rwlock_t *rwlock, const char *name) *****************************************************************/ static void thread_log_suspicious_usage(const char* from, const char* info) { - void *addresses[10]; - int num_addresses, i; - char **bt_symbols; - DEBUG(1,("log_suspicious_usage: from %s info='%s'\n", from, info)); #ifdef HAVE_BACKTRACE - num_addresses = backtrace(addresses, 8); - bt_symbols = backtrace_symbols(addresses, num_addresses); - for (i=0; i<num_addresses; i++) { - DEBUG(1,("log_suspicious_usage: %s%s\n", DEBUGTAB(1), bt_symbols[i])); + { + void *addresses[10]; + int num_addresses = backtrace(addresses, 8); + char **bt_symbols = backtrace_symbols(addresses, num_addresses); + int i; + + if (bt_symbols) { + for (i=0; i<num_addresses; i++) { + DEBUG(1,("log_suspicious_usage: %s%s\n", DEBUGTAB(1), bt_symbols[i])); + } + free(bt_symbols); + } } - free(bt_symbols); #endif } @@ -333,18 +336,21 @@ static void thread_log_suspicious_usage(const char* from, const char* info) *****************************************************************/ static void thread_print_suspicious_usage(const char* from, const char* info) { - void *addresses[10]; - int num_addresses, i; - char **bt_symbols; - printf("log_suspicious_usage: from %s info='%s'\n", from, info); #ifdef HAVE_BACKTRACE - num_addresses = backtrace(addresses, 8); - bt_symbols = backtrace_symbols(addresses, num_addresses); - for (i=0; i<num_addresses; i++) { - printf("log_suspicious_usage: %s%s\n", DEBUGTAB(1), bt_symbols[i]); + { + void *addresses[10]; + int num_addresses = backtrace(addresses, 8); + char **bt_symbols = backtrace_symbols(addresses, num_addresses); + int i; + + if (bt_symbols) { + for (i=0; i<num_addresses; i++) { + printf("log_suspicious_usage: %s%s\n", DEBUGTAB(1), bt_symbols[i]); + } + free(bt_symbols); + } } - free(bt_symbols); #endif } @@ -383,6 +389,9 @@ static void thread_fault_setup(void) #ifdef SIGBUS CatchSignal(SIGBUS,SIGNAL_CAST thread_sig_fault); #endif +#ifdef SIGABRT + CatchSignal(SIGABRT,SIGNAL_CAST thread_sig_fault); +#endif } /******************************************************************* @@ -391,9 +400,6 @@ report a fault in a thread static void thread_fault_handler(int sig) { static int counter; - void *addresses[10]; - int num_addresses, i; - char **bt_symbols; /* try to catch recursive faults */ thread_fault_setup(); @@ -405,12 +411,19 @@ static void thread_fault_handler(int sig) DEBUG(0,("Please read the file BUGS.txt in the distribution\n")); DEBUG(0,("===============================================================\n")); #ifdef HAVE_BACKTRACE - num_addresses = backtrace(addresses, 10); - bt_symbols = backtrace_symbols(addresses, num_addresses); - for (i=0; i<num_addresses; i++) { - DEBUG(9,("fault_report: %s\n", bt_symbols[i])); + { + void *addresses[10]; + int num_addresses = backtrace(addresses, 8); + char **bt_symbols = backtrace_symbols(addresses, num_addresses); + int i; + + if (bt_symbols) { + for (i=0; i<num_addresses; i++) { + DEBUG(1,("fault_report: %s%s\n", DEBUGTAB(1), bt_symbols[i])); + } + free(bt_symbols); + } } - free(bt_symbols); #endif pthread_exit(NULL); /* terminate failing thread only */ } |