From af366d4f5addfd07321fda8a29fcb1b6de49c5e7 Mon Sep 17 00:00:00 2001 From: skidder Date: Tue, 6 Apr 2004 07:25:45 +0000 Subject: [PATCH] Add BugcheckAbort option to produce coredumps on BUGCHECKs and structured exceptions --- builds/install/misc/firebird.conf | 15 +++++++++++++++ src/common/config/config.cpp | 6 ++++++ src/common/config/config.h | 8 +++++++- src/jrd/blob_filter.cpp | 1 + src/jrd/err.cpp | 2 ++ src/jrd/fun.epp | 3 ++- src/jrd/ibsetjmp.h | 12 +++++++----- src/jrd/isc_sync.cpp | 3 ++- 8 files changed, 42 insertions(+), 8 deletions(-) diff --git a/builds/install/misc/firebird.conf b/builds/install/misc/firebird.conf index aa29f3ac3c..bd872de756 100644 --- a/builds/install/misc/firebird.conf +++ b/builds/install/misc/firebird.conf @@ -245,6 +245,21 @@ #MaxUnflushedWriteTime = 5 +# ---------------------------- +# +# This option controls whether to call abort() when internal error or BUGCHECK +# is encountered thus invoke post-mortem debugger which can dump core suitable +# for off-line analysis. When disabled engine tries to minimize damage and +# continue execution. +# +# Note that setting this option to 1 makes POSIX SuperServer engine produce +# traceable coredumps when something nasty like SIGSEGV happens inside UDF. +# +# Type: boolean +# +#BugcheckAbort = 0 + + # ---------------------------- # Client Connection Settings (Basic) # diff --git a/src/common/config/config.cpp b/src/common/config/config.cpp index 5b2582b626..569976a8a0 100644 --- a/src/common/config/config.cpp +++ b/src/common/config/config.cpp @@ -106,6 +106,7 @@ const ConfigImpl::ConfigEntry ConfigImpl::entries[] = {TYPE_STRING, "DatabaseAccess", (ConfigValue) "Full"}, // location(s) of databases {TYPE_STRING, "UdfAccess", (ConfigValue) "Restrict UDF"}, // location(s) of UDFs {TYPE_STRING, "TempDirectories", (ConfigValue) 0}, + {TYPE_BOOLEAN, "BugcheckAbort", (ConfigValue) false}, // whether to abort() engine when internal error is found {TYPE_INTEGER, "TraceDSQL", (ConfigValue) 0} // bitmask }; @@ -469,6 +470,11 @@ const char *Config::getTempDirectories() return (const char*) sysConfig.values[KEY_TEMP_DIRECTORIES]; } +bool Config::getBugcheckAbort() +{ + return (bool) sysConfig.values[KEY_BUGCHECK_ABORT]; +} + int Config::getTraceDSQL() { return (int) sysConfig.values[KEY_TRACE_DSQL]; diff --git a/src/common/config/config.h b/src/common/config/config.h index 14798ba3d2..566840ec16 100644 --- a/src/common/config/config.h +++ b/src/common/config/config.h @@ -103,7 +103,8 @@ class Config KEY_DATABASE_ACCESS, // 38 KEY_UDF_ACCESS, // 39 KEY_TEMP_DIRECTORIES, // 40 - KEY_TRACE_DSQL // 41 + KEY_BUGCHECK_ABORT, // 41 + KEY_TRACE_DSQL // 42 }; public: @@ -317,6 +318,11 @@ public: DSQL trace bitmask */ static int getTraceDSQL(); + + /* + Abort on BUGCHECK and structured exceptions + */ + static bool getBugcheckAbort(); }; namespace Firebird { diff --git a/src/jrd/blob_filter.cpp b/src/jrd/blob_filter.cpp index 0e2e439a31..bfd07c2909 100644 --- a/src/jrd/blob_filter.cpp +++ b/src/jrd/blob_filter.cpp @@ -35,6 +35,7 @@ #include #include +#include "../common/config/config.h" #include "../jrd/common.h" #include "../jrd/jrd.h" #include "../jrd/y_ref.h" diff --git a/src/jrd/err.cpp b/src/jrd/err.cpp index 4dd76e3ba6..bba36b68c3 100644 --- a/src/jrd/err.cpp +++ b/src/jrd/err.cpp @@ -51,6 +51,7 @@ #include "../jrd/dbg_proto.h" #include "../jrd/err_proto.h" #include "../jrd/gds_proto.h" +#include "../common/config/config.h" using namespace Jrd; @@ -498,6 +499,7 @@ void ERR_punt(void) gds__log_status(tdbb->tdbb_attachment->att_filename ? tdbb->tdbb_attachment->att_filename.c_str() : NULL, tdbb->tdbb_status_vector); + if (Config::getBugcheckAbort()) abort(); } Firebird::status_exception::raise(tdbb->tdbb_status_vector); diff --git a/src/jrd/fun.epp b/src/jrd/fun.epp index 30d7692d21..86864e963d 100644 --- a/src/jrd/fun.epp +++ b/src/jrd/fun.epp @@ -30,13 +30,14 @@ * 2003.08.10 Claudio Valderrama: Fix SF Bugs #544132 and #728839. */ /* -$Id: fun.epp,v 1.45 2004-03-31 18:03:50 alexpeshkoff Exp $ +$Id: fun.epp,v 1.46 2004-04-06 07:25:45 skidder Exp $ */ #include "firebird.h" #include #include #include +#include "../common/config/config.h" #include "../jrd/common.h" #include "../jrd/jrd.h" #include "../jrd/val.h" diff --git a/src/jrd/ibsetjmp.h b/src/jrd/ibsetjmp.h index 3b9b4c5d8d..b6f5ee7bd6 100644 --- a/src/jrd/ibsetjmp.h +++ b/src/jrd/ibsetjmp.h @@ -46,11 +46,13 @@ #define START_CHECK_FOR_EXCEPTIONS(err) { \ SIGJMP_BUF sigenv; \ int sig; \ - memcpy(&tdbb->tdbb_sigsetjmp, &sigenv, sizeof sigenv); \ - if (sig = SIGSETJMP (sigenv, 1)) \ - ISC_exception_post(sig, err); \ - ISC_sync_signals_set(); -#define END_CHECK_FOR_EXCEPTIONS(err) ISC_sync_signals_reset(); } + if (!Config::getBugcheckAbort()) { \ + memcpy(&tdbb->tdbb_sigsetjmp, &sigenv, sizeof sigenv); \ + if (sig = SIGSETJMP (sigenv, 1)) \ + ISC_exception_post(sig, err); \ + ISC_sync_signals_set(); \ + } +#define END_CHECK_FOR_EXCEPTIONS(err) if (!Config::getBugcheckAbort()) ISC_sync_signals_reset(); } #endif /* SUPER_SERVER */ #endif /* UNIX */ diff --git a/src/jrd/isc_sync.cpp b/src/jrd/isc_sync.cpp index 7f5a0dad13..950509d7e6 100644 --- a/src/jrd/isc_sync.cpp +++ b/src/jrd/isc_sync.cpp @@ -1670,7 +1670,8 @@ ULONG ISC_exception_post(ULONG except_code, const TEXT* err_msg) if (is_critical) { - exit(3); + // Pass exception to outer handler in case debugger is present to collect memory dump + return EXCEPTION_CONTINUE_SEARCH; } else {