Skip to content

A config error aborts with a core dump (SIGABRT) instead of exiting cleanly #126

Closed

Description

@jrosskopf

What

initializeConfig(config_file) (src/main.cpp:574) is not inside a try/catch. Any exception it throws — an invalid flapi.yaml, a missing template directory, a malformed endpoint — reaches std::terminate, which flAPI has bound to terminateHandler (main.cpp:272):

void terminateHandler() {
    CROW_LOG_ERROR << "Unhandled exception caught! flapi is giving up :-(";
    ...
    std::abort();
}

The diagnostic is printed, which is good. But std::abort() raises SIGABRT, so a plain config typo produces a core dump and exit code 134.

Evidence

Found while clearing scratch space — the integration run had left core dumps behind:

Signal: 6 (ABRT)
Command Line: .../flapi -c /tmp/flapi_cfgchk_ztpdqb78/flapi.yaml -p 35091
 #3  terminateHandler
 #6  __cxa_throw
 #7  initializeConfig
 #8  main

Two 360 KB dumps from one test session. The config-check tests feed deliberately bad configs, so every such run leaves dumps on disk.

Why it matters

  • Operators: a typo in flapi.yaml looks like flAPI crashed, not like a config error. The exit code says "abnormal termination by signal", and the process dumps core.
  • Kubernetes / systemd: a container exiting on SIGABRT is reported as a crash; with a bad ConfigMap this is a crash-loop that reads as a flAPI defect rather than a configuration one.
  • Disk: on hosts with core dumps enabled, every restart attempt writes one. flAPI's binary is ~77 MB, so these are not small.

Suggested fix

Wrap startup config loading in a try/catch in main, print the diagnostic, and return 1. Keep terminateHandler for genuinely unexpected exceptions — that is what it is for.

Not done as part of the current refactor work: the exit code changes from 134 to 1, which is observable behaviour, and anything scripting flapi could be reading it. Needs an owner decision, not a quiet correction.

Activity

  1. jrosskopf commented on Sep 22, 2026

    @jrosskopf
    ContributorAuthor

    Fixed in #135 (merged as 23bd0f0).

    initializeConfig is now inside a try/catch in main: a configuration error is reported and exits 1 instead of reaching std::terminate and aborting with SIGABRT and a core dump. terminateHandler stays for genuinely unexpected exceptions, which is what it is for.

    Behaviour change: exit code 134 → 1.

    Covered by test/integration/test_config_error_exit.py — malformed YAML and a missing config file both exit cleanly, and the message names what is wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions