Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
@@ -1101,6 +1101,12 @@ static void throwSigSegV()
}
#endif
+static std::atomic<bool> processAborted { false };
+void jlib_decl setProcessAborted(bool _abortVal)
+{
+ processAborted = _abortVal;
+}
+
NO_SANITIZE("alignment") void excsighandler(int signum, siginfo_t *info, void *extra)
{
static byte nested=0;
@@ -1354,7 +1360,10 @@ NO_SANITIZE("alignment") void excsighandler(int signum, siginfo_t *info, void *e
if ( SEHHandler->fireException(new CSEHException(signum,s.str())) )
return;
- raise(signum);
+ if ( (SIGABRT == signum) && (processAborted) )
+ _exit(128 + SIGABRT);
+ else
+ raise(signum);
nested--;
@@ -129,6 +129,7 @@ void jlib_decl *setSEHtoExceptionHandler(IExceptionHandler *handler); // sets ha
void jlib_decl setTerminateOnSEHInSystemDLLs(bool set=true);
void jlib_decl setTerminateOnSEH(bool set=true);
+void jlib_decl setProcessAborted(bool _abortVal);
__declspec(noreturn) void jlib_decl throwUnexpectedException(const char * file, unsigned line) __attribute__((noreturn));
__declspec(noreturn) void jlib_decl throwUnexpectedException(const char * where, const char * file, unsigned line) __attribute__((noreturn));
@@ -1732,6 +1732,13 @@ void CGraphBase::abort(IException *e)
abortException.set(e);
aborted = true;
+ if (!job.getOptBool("coreOnAbort", false))
+ {
+ // prevent dtors throwing ... __verbose_terminate_handler()->abort()->raise()->core files
+ setProcessAborted(true);
+ }
graphCancelHandler.cancel(0);
if (0 == containers.count())
@@ -694,6 +694,9 @@ void CJobManager::run()
reply(workunit, wuid, MakeStringException(0, "Unknown exception"), agentep, false);
+ // reset for next job
+ setProcessAborted(false);
delete dp;
jobq.clear();
@@ -796,12 +796,21 @@ public:
~CThorSorter()
- stop();
- ActPrintLog(activity, "Joining Sort Slave Server");
- verifyex(threaded.join(10*60*1000));
- myendpoint.set(NULL,0);
- rowArray.kill();
- ActPrintLog(activity, "~CThorSorter");
+ try
+ stop();
+ ActPrintLog(activity, "Joining Sort Slave Server");
+ verifyex(threaded.join(10*60*1000));
+ myendpoint.set(NULL,0);
+ rowArray.kill();
+ ActPrintLog(activity, "~CThorSorter");
+ catch (IException *e)
+ e->Release();
+ // do we ignore other exceptions (...) here ?
+ // if so, we may have std::terminate call abort() ...
// ISortSlaveMP
virtual bool Connect(unsigned _partno, unsigned _numnodes)
@@ -1641,10 +1641,19 @@ public:
~CJobListener()
- for (unsigned sc=1; sc<channelsPerSlave; sc++)
- mpServers.item(sc).stop();
- mpServers.kill();
+ for (unsigned sc=1; sc<channelsPerSlave; sc++)
+ mpServers.item(sc).stop();
+ mpServers.kill();
void stop()
@@ -1863,6 +1872,10 @@ public:
jobs.removeExact(job);
PROGLOG("QueryDone, removed %s from jobs", key.get());
if (exception)
throw exception.getClear(); // NB: this will cause exception to be part of the reply to master