Skip to content

Commit

Permalink
Fix tail call optimisation in C++ backtrace capture
Browse files Browse the repository at this point in the history
  • Loading branch information
bamx23 committed May 4, 2024
1 parent 7bc2fc9 commit 3846149
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static KSStackCursor g_stackCursor;
#pragma mark - Callbacks -
// ============================================================================

static void captureStackTrace(void*, std::type_info*, void (*)(void*))
static void captureStackTrace(void*, std::type_info*, void (*)(void*)) __attribute__((disable_tail_calls))
{
if(g_captureNextStackTrace)
{
Expand All @@ -91,7 +91,7 @@ extern "C"
{
void __cxa_throw(void* thrown_exception, std::type_info* tinfo, void (*dest)(void*)) __attribute__ ((weak));

void __cxa_throw(void* thrown_exception, std::type_info* tinfo, void (*dest)(void*))
void __cxa_throw(void* thrown_exception, std::type_info* tinfo, void (*dest)(void*)) __attribute__((disable_tail_calls))
{
static cxa_throw_type orig_cxa_throw = NULL;
if (g_cxaSwapEnabled == false)
Expand Down
2 changes: 1 addition & 1 deletion Sources/KSCrashRecordingCore/KSStackCursor_SelfThread.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ typedef struct
uintptr_t backtrace[0];
} SelfThreadContext;

void kssc_initSelfThread(KSStackCursor *cursor, int skipEntries)
void kssc_initSelfThread(KSStackCursor *cursor, int skipEntries) __attribute__((disable_tail_calls))
{
SelfThreadContext* context = (SelfThreadContext*)cursor->context;
int backtraceLength = backtrace((void**)context->backtrace, MAX_BACKTRACE_LENGTH);
Expand Down

0 comments on commit 3846149

Please sign in to comment.