[pgpool-hackers: 3426] Signal handlers should not use ereport

Tatsuo Ishii ishii at sraoss.co.jp
Fri Sep 13 10:18:34 JST 2019


Currently there are a few places where signal handlers call ereport
(for example see below). ereport calls non-reentrant
functions. Calling non-reentrant functions inside signal handler is
prohibited (the reason can be found by googling. for example:
https://cwe.mitre.org/data/definitions/479.html).

To fix the problem there are several ways:

1) take out ereport call

2) block signal beginning of the signal handler

3) just set a variable to indicate signal is received and call ereport
   later on

#3 is ideal but needs more code. Probably #2 is a good compromise for
    now.

static RETSIGTYPE
hb_sender_exit(int sig)
{
	switch (sig)
	{
		case SIGTERM:			/* smart shutdown */
		case SIGINT:			/* fast shutdown */
		case SIGQUIT:			/* immediate shutdown */
			ereport(DEBUG1,
					(errmsg("watchdog heartbeat sender child receives shutdown request signal %d", sig)));

Best regards,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp


More information about the pgpool-hackers mailing list