Commit 4835cfa7 authored by Martin Marinov's avatar Martin Marinov

Prevent Progress::Context::abort() from throwing if we are in stack unwinding....

Prevent Progress::Context::abort() from throwing if we are in stack unwinding. This prevents abort() from terminating the application if we are already handling another exception and abort() is called inside a destructor.
parent 8f35e930
......@@ -6,6 +6,8 @@
#include "ProgressNode.hh"
#include "Base/Utils/BaseError.hh"
#include <exception>
#ifdef PROGRESS_ON
namespace Progress {
......@@ -17,7 +19,15 @@ Context::Context()
void Context::abort()
{
if (!abrt_alwd_)
// Don't throw if abort is not permitted or
// if there is stack unwinding currently in progress in this thread.
// Note that stack unwinding can be active, and it could be still possible to
// throw safely, see here:
// https://akrzemi1.wordpress.com/2011/09/21/destructors-that-throw/
// But we rather just wait until the current exception is handled.
if (!abrt_alwd_ || std::uncaught_exception())
return;
abrt_stte_ = AST_PROCESSING;
BASE_THROW_ERROR(PROGRESS_ABORTED);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment