agora inbox for pgpool-committers@postgresql.org  
help / color / mirror / Atom feed
pgpool: Convert pcp_exit_handler and wakeup_handler_parent to flag-only
6+ messages / 1 participants
[nested] [flat]

* pgpool: Convert pcp_exit_handler and wakeup_handler_parent to flag-only
@ 2026-09-16 09:12  Taiki Koshino <koshino@sraoss.co.jp>
  0 siblings, 0 replies; 6+ messages in thread

From: Taiki Koshino @ 2026-09-16 09:12 UTC (permalink / raw)
  To: pgpool-committers@lists.postgresql.org

Convert pcp_exit_handler and wakeup_handler_parent to flag-only.

The signal handlers in the PCP parent process directly accessed the
pcp_worker_children list and performed child-process cleanup. These
operations are not async-signal-safe and can modify or traverse the list
while the main loop is updating it.

In particular, pcp_exit_handler() can run while the main loop is adding
or removing worker entries. This can cause the handler to traverse a
partially modified list, crash, or send a signal to a reused PID.
wakeup_handler_parent() has the same risk when forwarding SIGUSR2 to
worker processes.

The handlers also call operations such as exit(), waitpid(), close(),
and Pgpool List functions from signal context.

Changes:
Flag-only Signal Handlers: Make pcp_exit_handler() and
wakeup_handler_parent() only set volatile sig_atomic_t flags and return.

Main-loop Processing: Process pending exit and wakeup requests from the
main loop, where the worker list can be accessed safely.

Direct Restart Cleanup: Update the PCP restart path to invoke the cleanup
function directly from normal process context.

Reported-by: Emond Papegaaij <emond.papegaaij@gmail.com>
Reported-by: Claude Code
Author: Taiki Koshino <koshino@sraoss.co.jp>
Discussion: https://www.postgresql.org/message-id/OS9P286MB6486FF7EC3D412F5D9B2E45F94AE2%40OS9P286MB6486.JPNP286...
Backpatch-through: v4.3

Branch
------
master

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=ab6ef59adeac0e00c803bdd210a7434c0a0e3...

Modified Files
--------------
src/pcp_con/pcp_child.c | 58 +++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 49 insertions(+), 9 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgpool: Convert pcp_exit_handler and wakeup_handler_parent to flag-only
@ 2026-09-16 09:13  Taiki Koshino <koshino@sraoss.co.jp>
  0 siblings, 0 replies; 6+ messages in thread

From: Taiki Koshino @ 2026-09-16 09:13 UTC (permalink / raw)
  To: pgpool-committers@lists.postgresql.org

Convert pcp_exit_handler and wakeup_handler_parent to flag-only.

The signal handlers in the PCP parent process directly accessed the
pcp_worker_children list and performed child-process cleanup. These
operations are not async-signal-safe and can modify or traverse the list
while the main loop is updating it.

In particular, pcp_exit_handler() can run while the main loop is adding
or removing worker entries. This can cause the handler to traverse a
partially modified list, crash, or send a signal to a reused PID.
wakeup_handler_parent() has the same risk when forwarding SIGUSR2 to
worker processes.

The handlers also call operations such as exit(), waitpid(), close(),
and Pgpool List functions from signal context.

Changes:
Flag-only Signal Handlers: Make pcp_exit_handler() and
wakeup_handler_parent() only set volatile sig_atomic_t flags and return.

Main-loop Processing: Process pending exit and wakeup requests from the
main loop, where the worker list can be accessed safely.

Direct Restart Cleanup: Update the PCP restart path to invoke the cleanup
function directly from normal process context.

Reported-by: Emond Papegaaij <emond.papegaaij@gmail.com>
Reported-by: Claude Code
Author: Taiki Koshino <koshino@sraoss.co.jp>
Discussion: https://www.postgresql.org/message-id/OS9P286MB6486FF7EC3D412F5D9B2E45F94AE2%40OS9P286MB6486.JPNP286...
Backpatch-through: v4.3

Branch
------
V4_7_STABLE

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=92003564bb049c49f4bab0adeb70db295dbc3...

Modified Files
--------------
src/pcp_con/pcp_child.c | 58 +++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 49 insertions(+), 9 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgpool: Convert pcp_exit_handler and wakeup_handler_parent to flag-only
@ 2026-09-16 09:14  Taiki Koshino <koshino@sraoss.co.jp>
  0 siblings, 0 replies; 6+ messages in thread

From: Taiki Koshino @ 2026-09-16 09:14 UTC (permalink / raw)
  To: pgpool-committers@lists.postgresql.org

Convert pcp_exit_handler and wakeup_handler_parent to flag-only.

The signal handlers in the PCP parent process directly accessed the
pcp_worker_children list and performed child-process cleanup. These
operations are not async-signal-safe and can modify or traverse the list
while the main loop is updating it.

In particular, pcp_exit_handler() can run while the main loop is adding
or removing worker entries. This can cause the handler to traverse a
partially modified list, crash, or send a signal to a reused PID.
wakeup_handler_parent() has the same risk when forwarding SIGUSR2 to
worker processes.

The handlers also call operations such as exit(), waitpid(), close(),
and Pgpool List functions from signal context.

Changes:
Flag-only Signal Handlers: Make pcp_exit_handler() and
wakeup_handler_parent() only set volatile sig_atomic_t flags and return.

Main-loop Processing: Process pending exit and wakeup requests from the
main loop, where the worker list can be accessed safely.

Direct Restart Cleanup: Update the PCP restart path to invoke the cleanup
function directly from normal process context.

Reported-by: Emond Papegaaij <emond.papegaaij@gmail.com>
Reported-by: Claude Code
Author: Taiki Koshino <koshino@sraoss.co.jp>
Discussion: https://www.postgresql.org/message-id/OS9P286MB6486FF7EC3D412F5D9B2E45F94AE2%40OS9P286MB6486.JPNP286...
Backpatch-through: v4.3

Branch
------
V4_6_STABLE

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=6d7cd44478b86ba27271d2875f2f26ca19e0f...

Modified Files
--------------
src/pcp_con/pcp_child.c | 58 +++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 49 insertions(+), 9 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgpool: Convert pcp_exit_handler and wakeup_handler_parent to flag-only
@ 2026-09-16 09:14  Taiki Koshino <koshino@sraoss.co.jp>
  0 siblings, 0 replies; 6+ messages in thread

From: Taiki Koshino @ 2026-09-16 09:14 UTC (permalink / raw)
  To: pgpool-committers@lists.postgresql.org

Convert pcp_exit_handler and wakeup_handler_parent to flag-only.

The signal handlers in the PCP parent process directly accessed the
pcp_worker_children list and performed child-process cleanup. These
operations are not async-signal-safe and can modify or traverse the list
while the main loop is updating it.

In particular, pcp_exit_handler() can run while the main loop is adding
or removing worker entries. This can cause the handler to traverse a
partially modified list, crash, or send a signal to a reused PID.
wakeup_handler_parent() has the same risk when forwarding SIGUSR2 to
worker processes.

The handlers also call operations such as exit(), waitpid(), close(),
and Pgpool List functions from signal context.

Changes:
Flag-only Signal Handlers: Make pcp_exit_handler() and
wakeup_handler_parent() only set volatile sig_atomic_t flags and return.

Main-loop Processing: Process pending exit and wakeup requests from the
main loop, where the worker list can be accessed safely.

Direct Restart Cleanup: Update the PCP restart path to invoke the cleanup
function directly from normal process context.

Reported-by: Emond Papegaaij <emond.papegaaij@gmail.com>
Reported-by: Claude Code
Author: Taiki Koshino <koshino@sraoss.co.jp>
Discussion: https://www.postgresql.org/message-id/OS9P286MB6486FF7EC3D412F5D9B2E45F94AE2%40OS9P286MB6486.JPNP286...
Backpatch-through: v4.3

Branch
------
V4_5_STABLE

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=911628dd37d3b85d1cb4d49621cd46f06f945...

Modified Files
--------------
src/pcp_con/pcp_child.c | 58 +++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 49 insertions(+), 9 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgpool: Convert pcp_exit_handler and wakeup_handler_parent to flag-only
@ 2026-09-16 09:16  Taiki Koshino <koshino@sraoss.co.jp>
  0 siblings, 0 replies; 6+ messages in thread

From: Taiki Koshino @ 2026-09-16 09:16 UTC (permalink / raw)
  To: pgpool-committers@lists.postgresql.org

Convert pcp_exit_handler and wakeup_handler_parent to flag-only.

The signal handlers in the PCP parent process directly accessed the
pcp_worker_children list and performed child-process cleanup. These
operations are not async-signal-safe and can modify or traverse the list
while the main loop is updating it.

In particular, pcp_exit_handler() can run while the main loop is adding
or removing worker entries. This can cause the handler to traverse a
partially modified list, crash, or send a signal to a reused PID.
wakeup_handler_parent() has the same risk when forwarding SIGUSR2 to
worker processes.

The handlers also call operations such as exit(), waitpid(), close(),
and Pgpool List functions from signal context.

Changes:
Flag-only Signal Handlers: Make pcp_exit_handler() and
wakeup_handler_parent() only set volatile sig_atomic_t flags and return.

Main-loop Processing: Process pending exit and wakeup requests from the
main loop, where the worker list can be accessed safely.

Direct Restart Cleanup: Update the PCP restart path to invoke the cleanup
function directly from normal process context.

Reported-by: Emond Papegaaij <emond.papegaaij@gmail.com>
Reported-by: Claude Code
Author: Taiki Koshino <koshino@sraoss.co.jp>
Discussion: https://www.postgresql.org/message-id/OS9P286MB6486FF7EC3D412F5D9B2E45F94AE2%40OS9P286MB6486.JPNP286...
Backpatch-through: v4.3

Branch
------
V4_4_STABLE

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=be13986bca08e0125f3c67ee82735e7d82a77...

Modified Files
--------------
src/pcp_con/pcp_child.c | 71 +++++++++++++++++++++++++++++++++++++++----------
1 file changed, 57 insertions(+), 14 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgpool: Convert pcp_exit_handler and wakeup_handler_parent to flag-only
@ 2026-09-16 09:17  Taiki Koshino <koshino@sraoss.co.jp>
  0 siblings, 0 replies; 6+ messages in thread

From: Taiki Koshino @ 2026-09-16 09:17 UTC (permalink / raw)
  To: pgpool-committers@lists.postgresql.org

Convert pcp_exit_handler and wakeup_handler_parent to flag-only.

The signal handlers in the PCP parent process directly accessed the
pcp_worker_children list and performed child-process cleanup. These
operations are not async-signal-safe and can modify or traverse the list
while the main loop is updating it.

In particular, pcp_exit_handler() can run while the main loop is adding
or removing worker entries. This can cause the handler to traverse a
partially modified list, crash, or send a signal to a reused PID.
wakeup_handler_parent() has the same risk when forwarding SIGUSR2 to
worker processes.

The handlers also call operations such as exit(), waitpid(), close(),
and Pgpool List functions from signal context.

Changes:
Flag-only Signal Handlers: Make pcp_exit_handler() and
wakeup_handler_parent() only set volatile sig_atomic_t flags and return.

Main-loop Processing: Process pending exit and wakeup requests from the
main loop, where the worker list can be accessed safely.

Direct Restart Cleanup: Update the PCP restart path to invoke the cleanup
function directly from normal process context.

Reported-by: Emond Papegaaij <emond.papegaaij@gmail.com>
Reported-by: Claude Code
Author: Taiki Koshino <koshino@sraoss.co.jp>
Discussion: https://www.postgresql.org/message-id/OS9P286MB6486FF7EC3D412F5D9B2E45F94AE2%40OS9P286MB6486.JPNP286...
Backpatch-through: v4.3

Branch
------
V4_3_STABLE

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=856fa78c8f9a9edc54c99eadf9121abe3336b...

Modified Files
--------------
src/pcp_con/pcp_child.c | 71 +++++++++++++++++++++++++++++++++++++++----------
1 file changed, 57 insertions(+), 14 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2026-09-16 09:17 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16 09:12 pgpool: Convert pcp_exit_handler and wakeup_handler_parent to flag-only Taiki Koshino <koshino@sraoss.co.jp>
2026-09-16 09:13 pgpool: Convert pcp_exit_handler and wakeup_handler_parent to flag-only Taiki Koshino <koshino@sraoss.co.jp>
2026-09-16 09:14 pgpool: Convert pcp_exit_handler and wakeup_handler_parent to flag-only Taiki Koshino <koshino@sraoss.co.jp>
2026-09-16 09:14 pgpool: Convert pcp_exit_handler and wakeup_handler_parent to flag-only Taiki Koshino <koshino@sraoss.co.jp>
2026-09-16 09:16 pgpool: Convert pcp_exit_handler and wakeup_handler_parent to flag-only Taiki Koshino <koshino@sraoss.co.jp>
2026-09-16 09:17 pgpool: Convert pcp_exit_handler and wakeup_handler_parent to flag-only Taiki Koshino <koshino@sraoss.co.jp>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox