Project

General

Profile

Bug #4865

some osmo projects don't generate coredump upon SIGABRT

Added by pespin 4 days ago. Updated 4 days ago.

Status:
New
Priority:
Normal
Assignee:
Target version:
-
Start date:
11/20/2020
Due date:
% Done:

0%

Spec Reference:

Description

See for instance osmo-bsc:

static void signal_handler(int signal)
{
    fprintf(stdout, "signal %u received\n", signal);

    switch (signal) {
    case SIGINT:
    case SIGTERM:
        bsc_shutdown_net(bsc_gsmnet);
        osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL);
        sleep(3);
        exit(0);
        break;
    case SIGABRT:
        /* in case of abort, we want to obtain a talloc report
         * and then return to the caller, who will abort the process */
    case SIGUSR1:
        talloc_report(tall_vty_ctx, stderr);
        talloc_report_full(tall_bsc_ctx, stderr);
        break;
    default:
        break;
    }
}

    signal(SIGINT, &signal_handler);
    signal(SIGTERM, &signal_handler);
    signal(SIGABRT, &signal_handler);
    signal(SIGUSR1, &signal_handler);
    signal(SIGUSR2, &signal_handler);

So when a process sends SIGABRT to it (killall -ABRT osmo-bsc), it will simply print talloc contexts and continue executing normally (and no coredump dumped). That's definetly not what we want here. Upon SIGABRT, we want the process to produce a coredump and exit.

In order to do so, after calling talloc_report we have to call the default SIGABRT handler.

That can be done by keeping reference to the older signal handler at startup when we voerride the signal:

sighandler_t default_sigabrt; /* global varialbe */
default_sigabrt = signal(SIGABRT, &signal_handler);

Then in our signal_handler:


static void signal_handler(int signal)
{
...
    case SIGABRT:
        talloc_report(tall_vty_ctx, stderr);
        talloc_report_full(tall_bsc_ctx, stderr);
        default_sigabrt(signal);
        break;
...
}

History

#1 Updated by laforge 4 days ago

Nice catch!

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 48.8 MB)