Skip to content

Commit

Permalink
Add: Backtrace output when a sigsegv occurs.
Browse files Browse the repository at this point in the history
When a sigsegv occurs in gvmd, a backtrace is now written to the logfile
if the appropriate log levels are set.

Merge pull request #1750 from jhelmold/print_backtrace_on_signal
  • Loading branch information
timopollmeier authored Dec 9, 2021
2 parents 1f0c28b + a4a3331 commit 8b30cd7
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/gvmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ handle_sigabrt (int given_signal)
frame_count = 0;
}
for (index = 0; index < frame_count; index++)
g_debug ("%s", frames_text[index]);
g_debug ("BACKTRACE: %s", frames_text[index]);
free (frames_text);
#endif

Expand Down Expand Up @@ -1035,6 +1035,24 @@ handle_termination_signal (int signal)
static void
handle_sigsegv (/* unused */ int given_signal)
{
#ifndef NDEBUG
void *frames[BA_SIZE];
int frame_count, index;
char **frames_text;

/* Print a backtrace. */
frame_count = backtrace (frames, BA_SIZE);
frames_text = backtrace_symbols (frames, frame_count);
if (frames_text == NULL)
{
perror ("backtrace symbols");
frame_count = 0;
}
for (index = 0; index < frame_count; index++)
g_debug ("BACKTRACE: %s", frames_text[index]);
free (frames_text);
#endif

manage_cleanup_process_error (given_signal);

/* This previously called "cleanup", but it seems that the regular manager
Expand Down

0 comments on commit 8b30cd7

Please sign in to comment.