From c750a06a241dc2737fa68c24b340a1bd82894f74 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 10 Jun 2018 23:28:40 -0400 Subject: [PATCH] remove unused trace function --- citadel/Makefile.in | 4 +- citadel/citserver.c | 81 ----- citadel/citserver.h | 5 +- citadel/context.c | 6 +- citadel/database.c | 4 - citadel/ecrash.c | 516 ------------------------------- citadel/ecrash.h | 185 ----------- citadel/modules/smtp/serv_smtp.c | 6 +- citadel/msgbase.c | 1 - citadel/server_main.c | 5 - citadel/sysdep.c | 13 - citadel/user_ops.h | 2 - citadel/utils/ctdlmigrate.c | 5 +- citadel/utils/setup.c | 5 +- 14 files changed, 11 insertions(+), 827 deletions(-) delete mode 100644 citadel/ecrash.c delete mode 100644 citadel/ecrash.h diff --git a/citadel/Makefile.in b/citadel/Makefile.in index ccbf0d2ac..2546f52e0 100644 --- a/citadel/Makefile.in +++ b/citadel/Makefile.in @@ -77,7 +77,7 @@ SOURCES=utils/citmail.c \ utillib/citadel_dirs.c \ citserver.c clientsocket.c config.c control.c $(DATABASE) \ domain.c serv_extensions.c genstamp.c \ - housekeeping.c ical_dezonify.c internet_addressing.c ecrash.c \ + housekeeping.c ical_dezonify.c internet_addressing.c \ locate_host.c auth.c msgbase.c parsedate.c \ room_ops.c euidindex.c server_main.c ldap.c \ support.c sysdep.c user_ops.c journaling.c threads.c \ @@ -134,7 +134,7 @@ SERV_OBJS = server_main.o utillib/citadel_dirs.o \ msgbase.o euidindex.o \ locate_host.o housekeeping.o ical_dezonify.o \ internet_addressing.o journaling.o \ - parsedate.o genstamp.o ecrash.o threads.o context.o \ + parsedate.o genstamp.o threads.o context.o \ clientsocket.o modules_init.o modules_upgrade.o $(SERV_MODULES) \ svn_revision.o ldap.o netconfig.o md5.o diff --git a/citadel/citserver.c b/citadel/citserver.c index 3ac69266d..06b31b944 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -18,9 +18,6 @@ #include #include "sysdep.h" #include -#if HAVE_BACKTRACE -#include -#endif #include #include "ctdl_module.h" @@ -37,84 +34,6 @@ time_t server_startup_time; int panic_fd; int openid_level_supported = 0; -/* - * print the actual stack frame. - */ -void cit_backtrace(void) -{ -#ifdef HAVE_BACKTRACE - void *stack_frames[50]; - size_t size, i; - char **strings; - - const char *p = IOSTR; - if (p == NULL) p = ""; - size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*)); - strings = backtrace_symbols(stack_frames, size); - for (i = 0; i < size; i++) { - if (strings != NULL) { - syslog(LOG_DEBUG, "citserver: %s %s", p, strings[i]); - } - else { - syslog(LOG_DEBUG, "citserver: %s %p", p, stack_frames[i]); - } - } - free(strings); -#endif -} - -void cit_oneline_backtrace(void) -{ -#ifdef HAVE_BACKTRACE - void *stack_frames[50]; - size_t size, i; - char **strings; - StrBuf *Buf; - - size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*)); - strings = backtrace_symbols(stack_frames, size); - if (size > 0) - { - Buf = NewStrBuf(); - for (i = 1; i < size; i++) { - if (strings != NULL) - StrBufAppendPrintf(Buf, "%s : ", strings[i]); - else - StrBufAppendPrintf(Buf, "%p : ", stack_frames[i]); - } - free(strings); - syslog(LOG_DEBUG, "citserver: %s %s", IOSTR, ChrPtr(Buf)); - FreeStrBuf(&Buf); - } -#endif -} - - -/* - * print the actual stack frame. - */ -void cit_panic_backtrace(int SigNum) -{ -#ifdef HAVE_BACKTRACE - void *stack_frames[10]; - size_t size, i; - char **strings; - - printf("caught signal 11\n"); - size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*)); - strings = backtrace_symbols(stack_frames, size); - for (i = 0; i < size; i++) { - if (strings != NULL) { - syslog(LOG_DEBUG, "%s", strings[i]); - } - else { - syslog(LOG_DEBUG, "%p", stack_frames[i]); - } - } - free(strings); -#endif - exit(-1); -} /* * Various things that need to be initialized at startup diff --git a/citadel/citserver.h b/citadel/citserver.h index cce5c51a2..5e7dfa31c 100644 --- a/citadel/citserver.h +++ b/citadel/citserver.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1987-2015 by the citadel.org team + * Copyright (c) 1987-2018 by the citadel.org team * * This program is open source software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3. @@ -35,9 +35,6 @@ struct UserProcList { #define CTDLUSERIP (IsEmptyStr(CC->cs_addr) ? CC->cs_clientinfo: CC->cs_addr) -void cit_backtrace(void); -void cit_oneline_backtrace(void); -void cit_panic_backtrace(int SigNum); void master_startup (void); int master_cleanup (int exitcode); void set_wtmpsupp (char *newtext); diff --git a/citadel/context.c b/citadel/context.c index 47da2679f..fd8b43ac2 100644 --- a/citadel/context.c +++ b/citadel/context.c @@ -15,7 +15,6 @@ #include "ctdl_module.h" #include "serv_extensions.h" -#include "ecrash.h" #include "citserver.h" #include "user_ops.h" #include "locate_host.h" @@ -72,9 +71,9 @@ int CtdlIsSingleUser(void) { /* check for only one context here */ if (num_sessions == 1) - return TRUE; + return 1; } - return FALSE; + return 0; } @@ -293,7 +292,6 @@ void RemoveContext (CitContext *con) c = "WTF?"; } syslog(LOG_DEBUG, "context: RemoveContext(%s) session %d", c, con->cs_pid); -/// cit_backtrace(); /* Run any cleanup routines registered by loadable modules. * Note: We have to "become_session()" because the cleanup functions diff --git a/citadel/database.c b/citadel/database.c index 4bd685d66..71eccbf78 100644 --- a/citadel/database.c +++ b/citadel/database.c @@ -63,7 +63,6 @@ void cdb_abort(void) { geteuid(), getegid() ); - cit_backtrace(); exit(CTDLEXIT_DB); } @@ -73,7 +72,6 @@ void cdb_verbose_log(const DB_ENV *dbenv, const char *msg) { if (!IsEmptyStr(msg)) { syslog(LOG_DEBUG, "db: %s", msg); - cit_backtrace(); } } @@ -83,7 +81,6 @@ void cdb_verbose_err(const DB_ENV *dbenv, const char *errpfx, const char *msg) { int *FOO = NULL; syslog(LOG_ERR, "db: %s", msg); - cit_backtrace(); *FOO = 1; } @@ -130,7 +127,6 @@ static void txbegin(DB_TXN ** tid) static void dbpanic(DB_ENV * env, int errval) { syslog(LOG_ERR, "db: PANIC: %s", db_strerror(errval)); - cit_backtrace(); } static void cclose(DBC * cursor) diff --git a/citadel/ecrash.c b/citadel/ecrash.c deleted file mode 100644 index ec91a02e4..000000000 --- a/citadel/ecrash.c +++ /dev/null @@ -1,516 +0,0 @@ -/* - * author: David Frascone - * - * eCrash Implementation - * - * eCrash will allow you to capture stack traces in the - * event of a crash, and write those traces to disk, stdout, - * or any other file handle. - * - * modified to integrate closer into citadel by Wilfried Goesgens - * - * vim: ts=4 - * - * This program is open source software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include "sysdep.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "server.h" -#include "sysdep_decls.h" -#include "support.h" -#include "config.h" -#include "citserver.h" -#include "ecrash.h" - -#define NIY() printf("function not implemented yet!\n"); -#ifdef HAVE_BACKTRACE -#include -static eCrashParameters gbl_params; - -static int gbl_backtraceEntries; -static void **gbl_backtraceBuffer; -static char **gbl_backtraceSymbols; -static int gbl_backtraceDoneFlag = 0; - -static void *stack_frames[50]; -static size_t size, NThread; -static char **strings; - -/* - * Private structures for our thread list - */ -typedef struct thread_list_node{ - char *threadName; - pthread_t thread; - int backtraceSignal; - sighandler_t oldHandler; - struct thread_list_node *Next; -} ThreadListNode; - -static pthread_mutex_t ThreadListMutex = PTHREAD_MUTEX_INITIALIZER; -static ThreadListNode *ThreadList = NULL; - -/********************************************************************* - ********************************************************************* - ** P R I V A T E F U N C T I O N S - ********************************************************************* - ********************************************************************/ - - -/*! - * Insert a node into our threadList - * - * @param name Text string indicating our thread - * @param thread Our Thread Id - * @param signo Signal to create backtrace with - * @param old_handler Our old handler for signo - * - * @returns zero on success - */ -static int addThreadToList(char *name, pthread_t thread,int signo, - sighandler_t old_handler) -{ - ThreadListNode *node; - - node = malloc(sizeof(ThreadListNode)); - if (!node) return -1; - - DPRINTF(ECRASH_DEBUG_VERBOSE, - "Adding thread 0x%08x (%s)\n", (unsigned int)thread, name); - node->threadName = strdup(name); - node->thread = thread; - node->backtraceSignal = signo; - node->oldHandler = old_handler; - - /* And, add it to the list */ - pthread_mutex_lock(&ThreadListMutex); - node->Next = ThreadList; - ThreadList = node; - pthread_mutex_unlock(&ThreadListMutex); - - return 0; - -} // addThreadToList - -/*! - * Remove a node from our threadList - * - * @param thread Our Thread Id - * - * @returns zero on success - */ -static int removeThreadFromList(pthread_t thread) -{ - ThreadListNode *Probe, *Prev=NULL; - ThreadListNode *Removed = NULL; - - DPRINTF(ECRASH_DEBUG_VERBOSE, - "Removing thread 0x%08x from list . . .\n", (unsigned int)thread); - pthread_mutex_lock(&ThreadListMutex); - for (Probe=ThreadList;Probe != NULL; Probe = Probe->Next) { - if (Probe->thread == thread) { - // We found it! Unlink it and move on! - Removed = Probe; - if (Prev == NULL) { // head of list - ThreadList = Probe->Next; - } else { - // Prev != null, so we need to link around ourselves. - Prev->Next = Probe->Next; - } - Removed->Next = NULL; - break; - } - - Prev = Probe; - } - pthread_mutex_unlock(&ThreadListMutex); - - // Now, if something is in Removed, free it, and return success - if (Removed) { - DPRINTF(ECRASH_DEBUG_VERBOSE, - " Found %s -- removing\n", Removed->threadName); - // Reset the signal handler - signal(Removed->backtraceSignal, Removed->oldHandler); - - // And free the allocated memory - free (Removed->threadName); - free (Removed); - - return 0; - } else { - DPRINTF(ECRASH_DEBUG_VERBOSE, - " Not Found\n"); - return -1; // Not Found - } -} // removeThreadFromList - -/*! - * Print out a line of output to all our destinations - * - * One by one, output a line of text to all of our output destinations. - * - * Return failure if we fail to output to any of them. - * - * @param format Normal printf style vararg format - * - * @returns nothing// bytes written, or error on failure. - */ -static void outputPrintf(char *format, ...) -{ - va_list ap; - - va_start(ap, format); - - vsyslog(LOG_CRIT|LOG_NDELAY|LOG_MAIL, format, ap); -} // outputPrintf - - - -/*! - * Dump our backtrace into a global location - * - * This function will dump out our backtrace into our - * global holding area. - * - */ -static void createGlobalBacktrace( void ) -{ - - size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*)); - for (NThread = 0; NThread < size; NThread++) - { - syslog(LOG_CRIT|LOG_NDELAY|LOG_MAIL, "RAW: %p ", stack_frames[NThread]); - } - strings = backtrace_symbols(stack_frames, size); - for (NThread = 0; NThread < size; NThread++) { - if (strings != NULL) { - syslog(LOG_CRIT|LOG_NDELAY|LOG_MAIL, "RAW: %p ", strings[NThread]); - } - } -} /* createGlobalBacktrace */ -static void outputRawtrace( void ) -{ - - size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*)); - for (NThread = 0; NThread < size; NThread++) - { - syslog(LOG_CRIT|LOG_NDELAY|LOG_MAIL, "RAW: %p ", stack_frames[NThread]); - } -} /* createGlobalBacktrace */ - -/*! - * Print out (to all the fds, etc), or global backtrace - */ -static void outputGlobalBacktrace ( void ) -{ - int i; - - for (i=0; i < gbl_backtraceEntries; i++) { - if (gbl_backtraceSymbols != FALSE) { - outputPrintf("* Frame %02x: %s\n", - i, gbl_backtraceSymbols[i]); - } else { - outputPrintf("* Frame %02x: %p\n", i, - gbl_backtraceBuffer[i]); - } - } -} // outputGlobalBacktrace - -/*! - * Output our current stack's backtrace - */ -static void outputBacktrace( void ) -{ - createGlobalBacktrace(); - outputGlobalBacktrace(); -} /* outputBacktrace */ - -static void outputBacktraceThreads( void ) -{ - ThreadListNode *probe; - int i; - - // When we're backtracing, don't worry about the mutex . . hopefully - // we're in a safe place. - - for (probe=ThreadList; probe; probe=probe->Next) { - gbl_backtraceDoneFlag = 0; - pthread_kill(probe->thread, probe->backtraceSignal); - for (i=0; i < gbl_params.threadWaitTime; i++) { - if (gbl_backtraceDoneFlag) - break; - sleep(1); - } - if (gbl_backtraceDoneFlag) { - outputPrintf("* Backtrace of \"%s\" (0x%08x)\n", - probe->threadName, (unsigned int)probe->thread); - outputGlobalBacktrace(); - } else { - outputPrintf("* Error: unable to get backtrace of \"%s\" (0x%08x)\n", - probe->threadName, (unsigned int)probe->thread); - } - outputPrintf("*\n"); - } -} // outputBacktraceThreads - - -/*! - * Handle signals (crash signals) - * - * This function will catch all crash signals, and will output the - * crash dump. - * - * It will physically write (and sync) the current thread's information - * before it attempts to send signals to other threads. - * - * @param signum Signal received. - */ -static void crash_handler(int signo) -{ - outputRawtrace(); - outputPrintf("*********************************************************\n"); - outputPrintf("* eCrash Crash Handler\n"); - outputPrintf("*********************************************************\n"); - outputPrintf("*\n"); - outputPrintf("* Got a crash! signo=%d\n", signo); - outputPrintf("*\n"); - outputPrintf("* Offending Thread's Backtrace:\n"); - outputPrintf("*\n"); - outputBacktrace(); - outputPrintf("*\n"); - - if (gbl_params.dumpAllThreads != FALSE) { - outputBacktraceThreads(); - } - - outputPrintf("*\n"); - outputPrintf("*********************************************************\n"); - outputPrintf("* eCrash Crash Handler\n"); - outputPrintf("*********************************************************\n"); - - exit(signo); -} // crash_handler - -/*! - * Handle signals (bt signals) - * - * This function shoudl be called to generate a crashdump into our - * global area. Once the dump has been completed, this function will - * return after tickling a global. Since mutexes are not async - * signal safe, the main thread, after signaling us to generate our - * own backtrace, will sleep for a few seconds waiting for us to complete. - * - * @param signum Signal received. - */ -static void bt_handler(int signo) -{ - createGlobalBacktrace(); - gbl_backtraceDoneFlag=1; -} // bt_handler - -/*! - * Validate a passed-in symbol table - * - * For now, just print it out (if verbose), and make sure it's - * sorted and none of the pointers are zero. - */ -static int ValidateSymbolTable( void ) -{ - int i; - int rc=0; - unsigned long lastAddress =0; - - // Get out of here if the table is empty - if (!gbl_params.symbolTable) return 0; - - // Dump it in verbose mode - DPRINTF(ECRASH_DEBUG_VERBOSE, - "Symbol Table Provided with %d symbols\n", - gbl_params.symbolTable->numSymbols); - for (i=0; i < gbl_params.symbolTable->numSymbols; i++){ - // Dump it in verbose mode - DPRINTF(ECRASH_DEBUG_VERBOSE, - "%-30s %p\n", - gbl_params.symbolTable->symbols[i].function, - gbl_params.symbolTable->symbols[i].address); - if (lastAddress > - (unsigned long)gbl_params.symbolTable->symbols[i].address) { - DPRINTF(ECRASH_DEBUG_ERROR, - "Error: symbol table is not sorted (last=%p, current=%p)\n", - (void *)lastAddress, - gbl_params.symbolTable->symbols[i].address); - rc = -1; - } - - } // for - - return rc; - -} // ValidateSymbolTable - -/********************************************************************* - ********************************************************************* - ** P U B L I C F U N C T I O N S - ********************************************************************* - ********************************************************************/ - -/*! - * Initialize eCrash. - * - * This function must be called before calling any other eCrash - * functions. It sets up the global behavior of the system, and - * registers the calling thread for crash dumps. - * - * @param params Our input parameters. The passed in structure will be copied. - * - * @return Zero on success. - */ -int eCrash_Init(eCrashParameters *params) -{ - int sigIndex; - int ret = 0; -#ifdef DO_SIGNALS_RIGHT - sigset_t blocked; - struct sigaction act; -#endif - - DPRINTF(ECRASH_DEBUG_VERY_VERBOSE,"Init Starting params = %p\n", params); - - if (params == NULL) return -1; - // Allocate our backtrace area - gbl_backtraceBuffer = malloc(sizeof(void *) * (params->maxStackDepth+5)); - -#ifdef DO_SIGNALS_RIGHT - sigemptyset(&blocked); - act.sa_sigaction = crash_handler; - act.sa_mask = blocked; - act.sa_flags = SA_SIGINFO; -#endif - - if (params != NULL) { - // Make ourselves a global copy of params. - gbl_params = *params; - gbl_params.filename = strdup(params->filename); - - // Set our defaults, if they weren't specified - if (gbl_params.maxStackDepth == 0 ) - gbl_params.maxStackDepth = ECRASH_DEFAULT_STACK_DEPTH; - - if (gbl_params.defaultBacktraceSignal == 0 ) - gbl_params.defaultBacktraceSignal = ECRASH_DEFAULT_BACKTRACE_SIGNAL; - - if (gbl_params.threadWaitTime == 0 ) - gbl_params.threadWaitTime = ECRASH_DEFAULT_THREAD_WAIT_TIME; - - if (gbl_params.debugLevel == 0 ) - gbl_params.debugLevel = ECRASH_DEBUG_DEFAULT; - - // Copy our symbol table - if (gbl_params.symbolTable) { - DPRINTF(ECRASH_DEBUG_VERBOSE, - "symbolTable @ %p -- %d symbols\n", gbl_params.symbolTable, - gbl_params.symbolTable->numSymbols); - // Make a copy of our symbol table - gbl_params.symbolTable = malloc(sizeof(eCrashSymbolTable)); - memcpy(gbl_params.symbolTable, params->symbolTable, - sizeof(eCrashSymbolTable)); - - // Now allocate / copy the actual table. - gbl_params.symbolTable->symbols = malloc(sizeof(eCrashSymbol) * - gbl_params.symbolTable->numSymbols); - memcpy(gbl_params.symbolTable->symbols, - params->symbolTable->symbols, - sizeof(eCrashSymbol) * gbl_params.symbolTable->numSymbols); - - ValidateSymbolTable(); - } - - // And, finally, register for our signals - for (sigIndex=0; gbl_params.signals[sigIndex] != 0; sigIndex++) { - DPRINTF(ECRASH_DEBUG_VERY_VERBOSE, - " Catching signal[%d] %d\n", sigIndex, - gbl_params.signals[sigIndex]); - - // I know there's a better way to catch signals with pthreads. - // I'll do it later TODO - signal(gbl_params.signals[sigIndex], crash_handler); - } - } else { - DPRINTF(ECRASH_DEBUG_ERROR, " Error: Null Params!\n"); - ret = -1; - } - DPRINTF(ECRASH_DEBUG_VERY_VERBOSE, "Init Complete ret=%d\n", ret); - return ret; -} /* eCrash_Init */ - -/*! - * UnInitialize eCrash. - * - * This function may be called to de-activate eCrash, release the - * signal handlers, and free any memory allocated by eCrash. - * - * @return Zero on success. - */ -int eCrash_Uninit( void ) -{ - NIY(); - - return 0; -} /* eCrash_Uninit */ - -/*! - * Register a thread for backtracing on crash. - * - * This function must be called by any thread wanting it's stack - * dumped in the event of a crash. The thread my specify what - * signal should be used, or the default, SIGUSR1 will be used. - * - * @param signo Signal to use to generate dump (default: SIGUSR1) - * - * @return Zero on success. - */ -int eCrash_RegisterThread(char *name, int signo) -{ - sighandler_t old_handler; - - // Register for our signal - if (signo == 0) { - signo = gbl_params.defaultBacktraceSignal; - } - - old_handler = signal(signo, bt_handler); - return addThreadToList(name, pthread_self(), signo, old_handler); - -} /* eCrash_RegisterThread */ - -/*! - * Un-register a thread for stack dumps. - * - * This function may be called to un-register any previously - * registered thread. - * - * @return Zero on success. - */ -int eCrash_UnregisterThread( void ) -{ - return removeThreadFromList(pthread_self()); -} /* eCrash_UnregisterThread */ - -#endif diff --git a/citadel/ecrash.h b/citadel/ecrash.h deleted file mode 100644 index e9fae9639..000000000 --- a/citadel/ecrash.h +++ /dev/null @@ -1,185 +0,0 @@ -/* - * eCrash.h - * David Frascone - * - * eCrash types and prototypes. - * - * vim: ts=4 - */ - -#ifndef _ECRASH_H_ -#define _ECRASH_H_ - -#include -#include - -typedef void (*sighandler_t)(int); - -typedef long BOOL; - -#define MAX_LINE_LEN 256 - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#define BOOL int -#endif - -#define ECRASH_DEFAULT_STACK_DEPTH 10 -#define ECRASH_DEFAULT_BACKTRACE_SIGNAL SIGUSR2 -#define ECRASH_DEFAULT_THREAD_WAIT_TIME 10 -#define ECRASH_MAX_NUM_SIGNALS 30 - -/** \struct eCrashSymbol - * \brief Function Name / Address pair - * - * This is used in conjunction with eCrashSymbolTable to - * provide an alternative to backtrace_symbols. - */ -typedef struct { - char *function; - void *address; -} eCrashSymbol; -/** \struct eCrashSymbolTable - * \brief Symbol table used to avoid backtrace_symbols() - * - * This structure is used to provide a alternative to - * backtrace_symbols which is not async signal safe. - * - * The symbol table should be sorted by address (it will - * be either binary or linearly searched) - */ -typedef struct { - int numSymbols; - eCrashSymbol *symbols; -} eCrashSymbolTable; - - - -#define ECRASH_DEBUG_ENABLE /* undef to turn off debug */ - -#ifdef ECRASH_DEBUG_ENABLE -# define ECRASH_DEBUG_VERY_VERBOSE 1 -# define ECRASH_DEBUG_VERBOSE 2 -# define ECRASH_DEBUG_INFO 3 -# define ECRASH_DEBUG_WARN 4 -# define ECRASH_DEBUG_ERROR 5 -# define ECRASH_DEBUG_OFF 6 -# define ECRASH_DEBUG_DEFAULT (ECRASH_DEBUG_ERROR) -# define DPRINTF(level, fmt...) \ - if (level >= gbl_params.debugLevel) { printf(fmt); fflush(stdout); } -#else /* ECRASH_DEBUG_ENABLE */ -# define DPRINTF(level, fmt...) -#endif /* ECRASH_DEBUG_ENABLE */ - - -/** \struct eCrashParameters - * \brief eCrash Initialization Parameters - * - * This structure contains all the global initialization functions - * for eCrash. - * - * @see eCrash_Init - */ -typedef struct { - - - /* OUTPUT OPTIONS */ - /** Filename to output to, or NULL */ - char *filename; - /** FILE * to output to or NULL */ - FILE *filep; - /** fd to output to or -1 */ - int fd; - - int debugLevel; - - /** If true, all registered threads will - * be dumped - */ - BOOL dumpAllThreads; - - /** How far to backtrace each stack */ - unsigned int maxStackDepth; - - /** Default signal to use to tell a thread to drop it's - * stack. - */ - int defaultBacktraceSignal; - - /** How long to wait for a threads - * dump - */ - unsigned int threadWaitTime; - - /** If this is non-zero, the dangerous function, backtrace_symbols - * will be used. That function does a malloc(), so is not async - * signal safe, and could cause deadlocks. - */ - BOOL useBacktraceSymbols; - - /** To avoid the issues with backtrace_symbols (see comments above) - * the caller can supply it's own symbol table, containing function - * names and start addresses. This table can be created using - * a script, or a static table. - * - * If this variable is not null, it will be used, instead of - * backtrace_symbols, reguardless of the setting - * of useBacktraceSymbols. - */ - eCrashSymbolTable *symbolTable; - - /** Array of crash signals to catch, - * ending in 0 I would have left it a [] array, but I - * do a static copy, so I needed a set size. - */ - int signals[ECRASH_MAX_NUM_SIGNALS]; - -} eCrashParameters; - -/*! - * Initialize eCrash. - * - * This function must be called before calling any other eCrash - * functions. It sets up the global behavior of the system. - * - * @param params Our input parameters. The passed in structure will be copied. - * - * @return Zero on success. - */ -int eCrash_Init(eCrashParameters *params); -/*! - * UnInitialize eCrash. - * - * This function may be called to de-activate eCrash, release the - * signal handlers, and free any memory allocated by eCrash. - * - * @return Zero on success. - */ -int eCrash_Uninit( void ); - -/*! - * Register a thread for backtracing on crash. - * - * This function must be called by any thread wanting it's stack - * dumped in the event of a crash. The thread my specify what - * signal should be used, or the default, SIGUSR1 will be used. - * - * @param name String used to refer to us in crash dumps - * @param signo Signal to use to generate dump (default: SIGUSR1) - * - * @return Zero on success. - */ -int eCrash_RegisterThread(char *name, int signo); - -/*! - * Un-register a thread for stack dumps. - * - * This function may be called to un-register any previously - * registered thread. - * - * @return Zero on success. - */ -int eCrash_UnregisterThread( void ); - -#endif /* _E_CRASH_H_ */ diff --git a/citadel/modules/smtp/serv_smtp.c b/citadel/modules/smtp/serv_smtp.c index e22881fa5..c8cd70173 100644 --- a/citadel/modules/smtp/serv_smtp.c +++ b/citadel/modules/smtp/serv_smtp.c @@ -116,7 +116,9 @@ void registerSmtpCMD(const char *First, long FLen, smtp_handler_hook *h; if (FLen >= MaxSMTPCmdLen) - cit_panic_backtrace (0); + { + abort(); + } h = (smtp_handler_hook*) malloc(sizeof(smtp_handler_hook)); memset(h, 0, sizeof(smtp_handler_hook)); @@ -1022,7 +1024,7 @@ void smtp_command_loop(void) if (sSMTP == NULL) { syslog(LOG_EMERG, "Session SMTP data is null. WTF? We will crash now."); - return cit_panic_backtrace (0); + abort(); } time(&CCC->lastcmd); diff --git a/citadel/msgbase.c b/citadel/msgbase.c index ec136d06c..6db04f8a1 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -2093,7 +2093,6 @@ int CtdlOutputPreLoadedMsg( if (!CM_IsValidMsg(TheMessage)) { syslog(LOG_ERR, "msgbase: error; invalid preloaded message for output"); - cit_backtrace (); return(om_no_such_msg); } diff --git a/citadel/server_main.c b/citadel/server_main.c index 536612ad7..f24a69edc 100644 --- a/citadel/server_main.c +++ b/citadel/server_main.c @@ -28,7 +28,6 @@ #include "serv_extensions.h" #include "citadel_dirs.h" #include "user_ops.h" -#include "ecrash.h" uid_t ctdluid = 0; const char *CitadelServiceUDS="citadel-UDS"; @@ -87,10 +86,6 @@ int main(int argc, char **argv) struct passwd *p = NULL; #ifdef HAVE_RUN_DIR struct stat filestats; -#endif -#ifdef HAVE_BACKTRACE - eCrashParameters params; -// eCrashSymbolTable symbol_table; #endif /* initialize the master context */ diff --git a/citadel/sysdep.c b/citadel/sysdep.c index d17e2bf15..ec320eeef 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -376,7 +376,6 @@ int client_write(const char *buf, int nbytes) fd = fopen(fn, "a+"); if (fd == NULL) { syslog(LOG_ERR, "%s: %m", fn); - cit_backtrace(); exit(1); } fprintf(fd, "Sending: BufSize: %d BufContent: [", nbytes); @@ -419,7 +418,6 @@ int client_write(const char *buf, int nbytes) } } else { syslog(LOG_ERR, "sysdep: client_write(%d bytes) select failed: %m", nbytes - bytes_written); - cit_backtrace(); client_close(); Ctx->kill_me = KILLME_SELECT_FAILED; return -1; @@ -430,7 +428,6 @@ int client_write(const char *buf, int nbytes) retval = write(Ctx->client_socket, &buf[bytes_written], nbytes - bytes_written); if (retval < 1) { syslog(LOG_ERR, "sysdep: client_write(%d bytes) failed: %m", nbytes - bytes_written); - cit_backtrace(); client_close(); Ctx->kill_me = KILLME_WRITE_FAILED; return -1; @@ -492,7 +489,6 @@ int client_read_blob(StrBuf *Target, int bytes, int timeout) fd = fopen(fn, "a+"); if (fd == NULL) { syslog(LOG_ERR, "%s: %m", fn); - cit_backtrace(); exit(1); } fprintf(fd, "Reading BLOB: BufSize: %d ", bytes); @@ -512,7 +508,6 @@ int client_read_blob(StrBuf *Target, int bytes, int timeout) fd = fopen(fn, "a+"); if (fd == NULL) { syslog(LOG_ERR, "%s: %m", fn); - cit_backtrace(); exit(1); } fprintf(fd, "Read: %d BufContent: [", StrLength(Target)); @@ -534,7 +529,6 @@ int client_read_blob(StrBuf *Target, int bytes, int timeout) fd = fopen(fn, "a+"); if (fd == NULL) { syslog(LOG_ERR, "%s: %m", fn); - cit_backtrace(); exit(1); } fprintf(fd, "Reading BLOB: BufSize: %d ", @@ -563,7 +557,6 @@ int client_read_blob(StrBuf *Target, int bytes, int timeout) fd = fopen(fn, "a+"); if (fd == NULL) { syslog(LOG_ERR, "%s: %m", fn); - cit_backtrace(); exit(1); } fprintf(fd, "Read: %d BufContent: [", @@ -622,7 +615,6 @@ int client_read_random_blob(StrBuf *Target, int timeout) fd = fopen(fn, "a+"); if (fd == NULL) { syslog(LOG_ERR, "%s: %m", fn); - cit_backtrace(); exit(1); } fprintf(fd, "Read: BufSize: %d BufContent: [", @@ -707,7 +699,6 @@ int CtdlClientGetLine(StrBuf *Target) fd = fopen(fn, "a+"); if (fd == NULL) { syslog(LOG_ERR, "%s: %m", fn); - cit_backtrace(); exit(1); } pch = ChrPtr(CCC->RecvBuf.Buf); @@ -765,7 +756,6 @@ int CtdlClientGetLine(StrBuf *Target) fd = fopen(fn, "a+"); if (fd == NULL) { syslog(LOG_ERR, "%s: %m", fn); - cit_backtrace(); exit(1); } pch = ChrPtr(CCC->RecvBuf.Buf); @@ -941,9 +931,6 @@ void sysdep_master_cleanup(void) { CtdlDestroyServiceHook(); CtdlDestroyRoomHooks(); CtdlDestroySearchHooks(); - #ifdef HAVE_BACKTRACE -/// eCrash_Uninit(); - #endif } diff --git a/citadel/user_ops.h b/citadel/user_ops.h index 44cf771e6..697554f13 100644 --- a/citadel/user_ops.h +++ b/citadel/user_ops.h @@ -66,7 +66,6 @@ static INLINE long cutuserkey(char *username) { if (len >= USERNAME_SIZE) { syslog(LOG_INFO, "Username too long: %s", username); - cit_backtrace (); len = USERNAME_SIZE - 1; username[len]='\0'; } @@ -84,7 +83,6 @@ static INLINE void makeuserkey(char *key, const char *username, long len) { if (len >= USERNAME_SIZE) { syslog(LOG_INFO, "Username too long: %s", username); - cit_backtrace (); len = USERNAME_SIZE - 1; } for (i=0; i<=len; ++i) { diff --git a/citadel/utils/ctdlmigrate.c b/citadel/utils/ctdlmigrate.c index 8fdfa3336..2a9a2d817 100644 --- a/citadel/utils/ctdlmigrate.c +++ b/citadel/utils/ctdlmigrate.c @@ -5,7 +5,7 @@ * The scope of this program isn't wide enough to make a difference. If you don't like * it you can rewrite it. * - * Copyright (c) 2009-2016 citadel.org + * Copyright (c) 2009-2018 citadel.org * * This program is open source software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3. @@ -41,9 +41,6 @@ #include "sysdep.h" #include "config.h" #include "citadel_dirs.h" -#if HAVE_BACKTRACE -#include -#endif diff --git a/citadel/utils/setup.c b/citadel/utils/setup.c index 2508712a2..27174c69b 100644 --- a/citadel/utils/setup.c +++ b/citadel/utils/setup.c @@ -1,7 +1,7 @@ /* * Citadel setup utility * - * Copyright (c) 1987-2017 by the citadel.org team + * Copyright (c) 1987-2018 by the citadel.org team * * This program is open source software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 3. @@ -36,9 +36,6 @@ #include "axdefs.h" #include "sysdep.h" #include "citadel_dirs.h" -#if HAVE_BACKTRACE -#include -#endif #ifdef ENABLE_NLS #ifdef HAVE_XLOCALE_H -- 2.30.2