osd: Stop on SIGINT/SIGTERM from the main loop, not the signal handler #141

Merged
vitalif merged 1 commits from koolkhel/vitastor:osd-signal-stop into master 2026-11-20 19:10:55 +03:00

1 Commits

Author SHA1 Message Date
7962b24aec osd: Stop on SIGINT/SIGTERM from the main loop, not the signal handler
The handler called osd_t::force_stop(), which builds a JSON object,
allocates strings and starts an HTTP request to etcd. None of that is
async-signal-safe. When the signal interrupts malloc() or free() in the
main loop, the handler re-enters the allocator and corrupts the heap,
and the OSD dies in malloc with SIGSEGV or SIGABRT instead of exiting
with 0.

Only set a flag in the handler, like the NBD, UBLK and NFS servers do,
and call force_stop() from the main loop. A second signal still exits
at once, now with _exit().
2026-11-20 16:29:05 +03:00