Skip to content

Commit

Permalink
Fix/CrashRpt: Linux build
Browse files Browse the repository at this point in the history
  • Loading branch information
TwinFan committed Dec 2, 2024
1 parent ba1c2af commit 82a2862
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Src/DataRefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,7 @@ void DataRefs::GetLabelColor (float outColor[4]) const
// return current a/c filter
std::string DataRefs::GetDebugAcFilter() const
{
char key[7];
char key[10];
if ( !uDebugAcFilter ) return std::string();

// convert to hex representation
Expand Down
17 changes: 9 additions & 8 deletions Src/ThreadCrashHdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,18 @@ void CrashHandlerRegister()
s_my_plugin_id = XPLMGetMyID();

#if APL || LIN
struct sigaction sig_action = { 0 };
struct sigaction sig_action = {};
sig_action.sa_sigaction = handle_posix_sig;

sigemptyset(&sig_action.sa_mask);

#if LIN
static uint8_t alternate_stack[SIGSTKSZ] = { 0 };
stack_t ss = { 0 };
ss.ss_sp = (void*)alternate_stack;
ss.ss_size = SIGSTKSZ:
ss.ss_flags = 0:
// SIGSTKSZ is no longer a constant, at least on GNU, so we need to dynamically allocate the memory here
static std::vector<uint8_t> alternate_stack(SIGSTKSZ);
stack_t ss = {};
ss.ss_sp = (void*)alternate_stack.data();
ss.ss_size = SIGSTKSZ;
ss.ss_flags = 0;

sigaltstack(&ss, NULL);
sig_action.sa_flags = SA_SIGINFO | SA_ONSTACK;
Expand Down Expand Up @@ -336,7 +337,7 @@ void handle_crash(EXCEPTION_POINTERS *ei)
tm.tm_hour, tm.tm_min, tm.tm_sec);

#if APL || LIN
// NOTE: Laminar's post doesn't consider this safe enough for production
// NOTE: Laminar's post doesn't consider the following safe enough for production
// as backtrace is NOT signal handler safe (backtrace_symbols_fd supposingly is),
// but in my tests it seems 'good enough' for the purpose and did write
// proper output at least for the most typical case of SIGSEGV.
Expand All @@ -356,7 +357,7 @@ void handle_crash(EXCEPTION_POINTERS *ei)
#endif
crash_thread_name,
sig);
write (fd, sz, strlen(sz));
(void) write (fd, sz, strlen(sz));
backtrace_symbols_fd(frames, frame_count, fd);
close(fd);
}
Expand Down

1 comment on commit 82a2862

@TwinFan
Copy link
Owner Author

@TwinFan TwinFan commented on 82a2862 Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to #193

Please sign in to comment.