Add ABORT_ON_ASSERT flag to CONFIG_SITE
This flag causes EPICS to call abort() on assertion failures rather than suspend the executing thread. With the epicsThreadSuspendSelf() behavior, an IOC can end up in a difficult to detect error state where one or more threads has essentially crashed due to an assertion failure. This also matches the C behavior of assert(3)
This commit is contained in:

committed by
Michael Davidsaver

parent
0186836449
commit
721e9cc3a7
@ -92,3 +92,6 @@ EPICS_IOC_LOG_FILE_NAME=
|
|||||||
EPICS_IOC_LOG_FILE_COMMAND=
|
EPICS_IOC_LOG_FILE_COMMAND=
|
||||||
EPICS_IOC_LOG_FILE_LIMIT=1000000
|
EPICS_IOC_LOG_FILE_LIMIT=1000000
|
||||||
|
|
||||||
|
# Set to 'YES' to call abort() rather than suspend the current thread
|
||||||
|
# when an assert() fails
|
||||||
|
EPICS_ABORT_ON_ASSERT=NO
|
||||||
|
1
modules/libcom/src/env/envDefs.h
vendored
1
modules/libcom/src/env/envDefs.h
vendored
@ -76,6 +76,7 @@ LIBCOM_API extern const ENV_PARAM EPICS_IOC_LOG_FILE_COMMAND;
|
|||||||
LIBCOM_API extern const ENV_PARAM IOCSH_PS1;
|
LIBCOM_API extern const ENV_PARAM IOCSH_PS1;
|
||||||
LIBCOM_API extern const ENV_PARAM IOCSH_HISTSIZE;
|
LIBCOM_API extern const ENV_PARAM IOCSH_HISTSIZE;
|
||||||
LIBCOM_API extern const ENV_PARAM IOCSH_HISTEDIT_DISABLE;
|
LIBCOM_API extern const ENV_PARAM IOCSH_HISTEDIT_DISABLE;
|
||||||
|
LIBCOM_API extern const ENV_PARAM EPICS_ABORT_ON_ASSERT;
|
||||||
LIBCOM_API extern const ENV_PARAM *env_param_list[];
|
LIBCOM_API extern const ENV_PARAM *env_param_list[];
|
||||||
|
|
||||||
struct in_addr;
|
struct in_addr;
|
||||||
|
@ -20,12 +20,14 @@
|
|||||||
#include "epicsTime.h"
|
#include "epicsTime.h"
|
||||||
#include "cantProceed.h"
|
#include "cantProceed.h"
|
||||||
#include "epicsStackTrace.h"
|
#include "epicsStackTrace.h"
|
||||||
|
#include "envDefs.h"
|
||||||
|
|
||||||
|
|
||||||
void epicsAssert (const char *pFile, const unsigned line,
|
void epicsAssert (const char *pFile, const unsigned line,
|
||||||
const char *pExp, const char *pAuthorName)
|
const char *pExp, const char *pAuthorName)
|
||||||
{
|
{
|
||||||
epicsTimeStamp current;
|
epicsTimeStamp current;
|
||||||
|
int shouldAbort = 0;
|
||||||
|
|
||||||
errlogPrintf("\n\n\n"
|
errlogPrintf("\n\n\n"
|
||||||
"A call to 'assert(%s)'\n"
|
"A call to 'assert(%s)'\n"
|
||||||
@ -50,6 +52,13 @@ void epicsAssert (const char *pFile, const unsigned line,
|
|||||||
errlogPrintf("Please E-mail this message to %s or to tech-talk@aps.anl.gov\n",
|
errlogPrintf("Please E-mail this message to %s or to tech-talk@aps.anl.gov\n",
|
||||||
pAuthorName);
|
pAuthorName);
|
||||||
|
|
||||||
|
if (envGetBoolConfigParam(&EPICS_ABORT_ON_ASSERT, &shouldAbort) == 0 && shouldAbort) {
|
||||||
|
errlogPrintf("Calling abort()\n");
|
||||||
|
errlogFlush();
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
else {
|
||||||
errlogPrintf("Calling epicsThreadSuspendSelf()\n");
|
errlogPrintf("Calling epicsThreadSuspendSelf()\n");
|
||||||
epicsThreadSuspendSelf ();
|
epicsThreadSuspendSelf ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user