Skip to content

mpm_worker: exit at once from just_die(), as mpm_event - #1132

Merged
ylavic merged 1 commit into
apache:trunkfrom
ylavic:trunk-worker-just-die
Nov 30, 2026
Merged

ylavic merged 1 commit into
apache:trunkfrom
ylavic:trunk-worker-just-die

Conversation

@ylavic

@ylavic ylavic commented Nov 30, 2026

Copy link
Copy Markdown
Member

just_die() is the SIGTERM handler a worker child installs right after fork(), until child_main() blocks the signals (apr_setup_signal_thread()) and handles SIGTERM synchronously (apr_signal_thread(check_signal)). It called clean_child_exit(0), so the child_stopping/child_stopped hooks, apr_pool_destroy(pchild) and exit() ran from the signal handler. None of that is async-signal-safe: if the interrupted thread is inside malloc() or holds a lock those need, the child can hang or corrupt its heap.

This is the same issue #1020 (PR 70267) fixed in mpm_event, and the same fix: nothing set up that early needs cleaning, so just_die() now just calls _exit(0).

It also matters for backporting the child_stopped hook to 2.4.x (r1898369, with mod_watchdog's use of it): without this, 2.4.x's worker would start running child_stopped, which joins the watchdog threads, from a signal handler. (mpm_prefork skips the hooks from its signal handler since r1898418; there just_die() is the normal ungraceful exit, so it keeps its cleanup.)

just_die(), a child's SIGTERM handler until child_main() handles signals
itself, ran clean_child_exit() (hooks, pool destruction, exit()), which is
not async-signal-safe. Nothing needs cleaning that early: just _exit(0),
as mpm_event since PR 70267.

* server/mpm/worker/worker.c (just_die):
  _exit(0) rather than clean_child_exit(0).

* changes-entries/worker-just-die.txt: New.
@ylavic
ylavic force-pushed the trunk-worker-just-die branch from 868b089 to ab71937 Compare November 30, 2026 11:19
@ylavic
ylavic merged commit 2343542 into apache:trunk Nov 30, 2026
17 of 46 checks passed
@ylavic
ylavic deleted the trunk-worker-just-die branch November 30, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant