Browse Source

Handle stack unwind for carla's "safe" exceptions

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.1-rc2
falkTX 4 years ago
parent
commit
508f2276d1
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 17 additions and 9 deletions
  1. +1
    -1
      source/backend/utils/PipeClient.cpp
  2. +14
    -4
      source/includes/CarlaDefines.h
  3. +1
    -4
      source/utils/CarlaThread.hpp
  4. +1
    -0
      source/utils/CarlaUtils.hpp

+ 1
- 1
source/backend/utils/PipeClient.cpp View File

@@ -60,7 +60,7 @@ public:
#endif
}

const char* idlePipeAndReturnMessage()
const char* idlePipeAndReturnMessage() noexcept
{
CarlaPipeClient::idlePipe();



+ 14
- 4
source/includes/CarlaDefines.h View File

@@ -191,11 +191,21 @@
#define CARLA_SAFE_ASSERT_UINT2_CONTINUE(cond, v1, v2) if (! (cond)) { carla_safe_assert_uint2(#cond, __FILE__, __LINE__, static_cast<uint>(v1), static_cast<uint>(v2)); continue; }
#define CARLA_SAFE_ASSERT_UINT2_RETURN(cond, v1, v2, ret) if (! (cond)) { carla_safe_assert_uint2(#cond, __FILE__, __LINE__, static_cast<uint>(v1), static_cast<uint>(v2)); return ret; }

#if defined(__GNUC__) && defined(CARLA_PROPER_CPP11_SUPPORT)
# define CARLA_CATCH_UNWIND catch (abi::__forced_unwind&) { throw; }
# if __GNUC__ >= 6
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wterminate"
# endif
#else
# define CARLA_CATCH_UNWIND
#endif

/* Define CARLA_SAFE_EXCEPTION */
#define CARLA_SAFE_EXCEPTION(msg) catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); }
#define CARLA_SAFE_EXCEPTION_BREAK(msg) catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); break; }
#define CARLA_SAFE_EXCEPTION_CONTINUE(msg) catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); continue; }
#define CARLA_SAFE_EXCEPTION_RETURN(msg, ret) catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); return ret; }
#define CARLA_SAFE_EXCEPTION(msg) CARLA_CATCH_UNWIND catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); }
#define CARLA_SAFE_EXCEPTION_BREAK(msg) CARLA_CATCH_UNWIND catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); break; }
#define CARLA_SAFE_EXCEPTION_CONTINUE(msg) CARLA_CATCH_UNWIND catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); continue; }
#define CARLA_SAFE_EXCEPTION_RETURN(msg, ret) CARLA_CATCH_UNWIND catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); return ret; }

/* Define CARLA_DECLARE_NON_COPY_CLASS */
#ifdef CARLA_PROPER_CPP11_SUPPORT


+ 1
- 4
source/utils/CarlaThread.hpp View File

@@ -197,10 +197,7 @@ public:
_copyTo(threadId);
_init();

try {
pthread_cancel(threadId);
} CARLA_SAFE_EXCEPTION("pthread_cancel");

pthread_detach(threadId);
return false;
}
}


+ 1
- 0
source/utils/CarlaUtils.hpp View File

@@ -27,6 +27,7 @@
#include <cstring>

#ifdef CARLA_PROPER_CPP11_SUPPORT
# include <cxxabi.h>
# include <cstdint>
#else
# include <stdint.h>


Loading…
Cancel
Save