public inbox for [email protected]  
help / color / mirror / Atom feed
"buffer overflow detected" when running SHOW POOL_STATUS
6+ messages / 2 participants
[nested] [flat]

* "buffer overflow detected" when running SHOW POOL_STATUS
@ 2025-11-27 18:55 zam bak <[email protected]>
  2025-11-30 01:27 ` Re: "buffer overflow detected" when running SHOW POOL_STATUS Tatsuo Ishii <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: zam bak @ 2025-11-27 18:55 UTC (permalink / raw)
  To: [email protected]

Hello

I am using the latest pgpool-II v4.6.4 on Rocky Linux v10.1
(installation via RPMs) with PostgreSQL 18 (one primary, one replica,
streaming replication)
When attempting to run POOL_STATUS command, either as SQL or via pcp,
I am getting "buffer overflow detected" in the log.
Here are the contents of the log from both SQL and pcp commands:

1)
sudo -u postgres pcp_pool_status -w -v -h localhost -p 9898 -U postgres

2025-11-27 13:30:19.298 [4486]: [3-1] user=[No Connection],db=[No
Connection],app=pcp_main LOG:  forked new pcp worker, pid=4495
socket=7
2025-11-27 13:30:19.298 [4486]: [4-1] user=[No Connection],db=[No
Connection],app=pcp_main LOCATION:  pcp_child.c:327
*** buffer overflow detected ***: terminated
2025-11-27 13:30:20.315 [4486]: [5-1] user=[No Connection],db=[No
Connection],app=pcp_main LOG:  PCP process with pid: 4495 exits with
status 134 by signal 6
2025-11-27 13:30:20.315 [4486]: [6-1] user=[No Connection],db=[No
Connection],app=pcp_main LOCATION:  pcp_child.c:394

2)
sudo -u postgres psql -w -h localhost -p 9999 -U postgres -c "SHOW POOL_STATUS"

2025-11-27 13:31:34.385 [4390]: [1-1]
user=postgres,db=postgres,app=psql LOG:  DB node id: 0 backend pid:
10166 statement: SELECT pg_catalog.version()
2025-11-27 13:31:34.385 [4390]: [2-1]
user=postgres,db=postgres,app=psql LOCATION:
pool_proto_modules.c:3803
*** buffer overflow detected ***: terminated



And here is my pgpool.conf file (only changed lines - diff compared to
pgpool.conf.sample)
diff --unchanged-line-format= --old-line-format=
--new-line-format='%L' pgpool.conf.sample pgpool.conf

listen_addresses = '*'
unix_socket_directories = '/var/run/pgpool'
pcp_socket_dir = '/var/run/pgpool'
serialize_accept = on
backend_hostname0 = '192.168.68.104'
backend_port0 = 5432
backend_weight0 = 1
backend_data_directory0 = '/data/pgdata/18'
backend_flag0 = 'ALWAYS_PRIMARY'
backend_application_name0 = 'primary'
backend_hostname1 = '192.168.68.105'
backend_port1 = 5432
backend_weight1 = 1
backend_data_directory1 = '/data/pgdata/18'
backend_flag1 = 'DISALLOW_TO_FAILOVER'
backend_application_name1 = 'replica_1'
num_init_children = 96
max_pool = 2
child_life_time = 0
log_line_prefix = '%m [%p]: [%l-1] user=%u,db=%d,app=%a '   #
printf-style string to output at beginning of each log line.
log_connections = off
log_disconnections = off
log_per_node_statement = on
log_standby_delay = 'always'
log_error_verbosity = verbose          # terse, default, or verbose messages
log_filename = 'pgpool-01-%a.log'
write_function_list =
'currval,lastval,nextval,setval,public.upgrade_.*,upgrade_.*,public.update_.*,update_.*,public.selsert_.*,selsert_.*,public.purge_.*,purge_.*,public.process_.*,process_.*,public.move_.*,move_.*,public.merge_.*,merge_.*,public.mark_.*,mark_.*,billing.can_ahs_claim_charge,billing.can_ahs_apply_.*'
statement_level_load_balance = on
sr_check_period = 5s
sr_check_user = 'pgpool_monitor'
delay_threshold_by_time = 500ms
health_check_period = 10
health_check_timeout = 30
health_check_user = 'pgpool_monitor'
health_check_max_retries = 10
failover_on_backend_error = off
check_temp_table = trace





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

* Re: "buffer overflow detected" when running SHOW POOL_STATUS
  2025-11-27 18:55 "buffer overflow detected" when running SHOW POOL_STATUS zam bak <[email protected]>
@ 2025-11-30 01:27 ` Tatsuo Ishii <[email protected]>
  2025-12-01 14:42   ` Re: "buffer overflow detected" when running SHOW POOL_STATUS zam bak <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Tatsuo Ishii @ 2025-11-30 01:27 UTC (permalink / raw)
  To: [email protected]; +Cc: [email protected]

Hello,

Thank you for the report!

Unfortunately, I was not able to reproduce the issue on my Ubuntu 24
and Rocky Linux 10.1 box (pgpool is compiled from source code).
So there are some questions:

- Is the issue occurred even when you execute other pgpool command?
  (for example "show pool_processes")

- I found a problem with the output of "show pool_status". The value
  of "memqcache_stats_start_time" is shown with newline and an empty
  item followed. I am not sure if this is related to your issue. If
  possible, can you please try the attached patch?

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

> Hello
> 
> I am using the latest pgpool-II v4.6.4 on Rocky Linux v10.1
> (installation via RPMs) with PostgreSQL 18 (one primary, one replica,
> streaming replication)
> When attempting to run POOL_STATUS command, either as SQL or via pcp,
> I am getting "buffer overflow detected" in the log.
> Here are the contents of the log from both SQL and pcp commands:
> 
> 1)
> sudo -u postgres pcp_pool_status -w -v -h localhost -p 9898 -U postgres
> 
> 2025-11-27 13:30:19.298 [4486]: [3-1] user=[No Connection],db=[No
> Connection],app=pcp_main LOG:  forked new pcp worker, pid=4495
> socket=7
> 2025-11-27 13:30:19.298 [4486]: [4-1] user=[No Connection],db=[No
> Connection],app=pcp_main LOCATION:  pcp_child.c:327
> *** buffer overflow detected ***: terminated
> 2025-11-27 13:30:20.315 [4486]: [5-1] user=[No Connection],db=[No
> Connection],app=pcp_main LOG:  PCP process with pid: 4495 exits with
> status 134 by signal 6
> 2025-11-27 13:30:20.315 [4486]: [6-1] user=[No Connection],db=[No
> Connection],app=pcp_main LOCATION:  pcp_child.c:394
> 
> 2)
> sudo -u postgres psql -w -h localhost -p 9999 -U postgres -c "SHOW POOL_STATUS"
> 
> 2025-11-27 13:31:34.385 [4390]: [1-1]
> user=postgres,db=postgres,app=psql LOG:  DB node id: 0 backend pid:
> 10166 statement: SELECT pg_catalog.version()
> 2025-11-27 13:31:34.385 [4390]: [2-1]
> user=postgres,db=postgres,app=psql LOCATION:
> pool_proto_modules.c:3803
> *** buffer overflow detected ***: terminated
> 
> 
> 
> And here is my pgpool.conf file (only changed lines - diff compared to
> pgpool.conf.sample)
> diff --unchanged-line-format= --old-line-format=
> --new-line-format='%L' pgpool.conf.sample pgpool.conf
> 
> listen_addresses = '*'
> unix_socket_directories = '/var/run/pgpool'
> pcp_socket_dir = '/var/run/pgpool'
> serialize_accept = on
> backend_hostname0 = '192.168.68.104'
> backend_port0 = 5432
> backend_weight0 = 1
> backend_data_directory0 = '/data/pgdata/18'
> backend_flag0 = 'ALWAYS_PRIMARY'
> backend_application_name0 = 'primary'
> backend_hostname1 = '192.168.68.105'
> backend_port1 = 5432
> backend_weight1 = 1
> backend_data_directory1 = '/data/pgdata/18'
> backend_flag1 = 'DISALLOW_TO_FAILOVER'
> backend_application_name1 = 'replica_1'
> num_init_children = 96
> max_pool = 2
> child_life_time = 0
> log_line_prefix = '%m [%p]: [%l-1] user=%u,db=%d,app=%a '   #
> printf-style string to output at beginning of each log line.
> log_connections = off
> log_disconnections = off
> log_per_node_statement = on
> log_standby_delay = 'always'
> log_error_verbosity = verbose          # terse, default, or verbose messages
> log_filename = 'pgpool-01-%a.log'
> write_function_list =
> 'currval,lastval,nextval,setval,public.upgrade_.*,upgrade_.*,public.update_.*,update_.*,public.selsert_.*,selsert_.*,public.purge_.*,purge_.*,public.process_.*,process_.*,public.move_.*,move_.*,public.merge_.*,merge_.*,public.mark_.*,mark_.*,billing.can_ahs_claim_charge,billing.can_ahs_apply_.*'
> statement_level_load_balance = on
> sr_check_period = 5s
> sr_check_user = 'pgpool_monitor'
> delay_threshold_by_time = 500ms
> health_check_period = 10
> health_check_timeout = 30
> health_check_user = 'pgpool_monitor'
> health_check_max_retries = 10
> failover_on_backend_error = off
> check_temp_table = trace
> 
> 


Attachments:

  [text/x-patch] pool_status.patch (615B, 2-pool_status.patch)
  download | inline diff:
diff --git a/src/utils/pool_process_reporting.c b/src/utils/pool_process_reporting.c
index e4fcf4457..9e677d95e 100644
--- a/src/utils/pool_process_reporting.c
+++ b/src/utils/pool_process_reporting.c
@@ -1117,6 +1117,8 @@ get_config(int *nrows)
 
 	StrNCpy(status[i].name, "memqcache_stats_start_time", POOLCONFIG_MAXNAMELEN);
 	snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", ctime(&pool_get_memqcache_stats()->start_time));
+	/* remove a newline added by ctime() */
+	*(strchrnul(status[i].value, '\n')) = '\0';
 	StrNCpy(status[i].desc, "Start time of query cache stats", POOLCONFIG_MAXDESCLEN);
 	i++;
 


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

* Re: "buffer overflow detected" when running SHOW POOL_STATUS
  2025-11-27 18:55 "buffer overflow detected" when running SHOW POOL_STATUS zam bak <[email protected]>
  2025-11-30 01:27 ` Re: "buffer overflow detected" when running SHOW POOL_STATUS Tatsuo Ishii <[email protected]>
@ 2025-12-01 14:42   ` zam bak <[email protected]>
  2025-12-02 05:02     ` Re: "buffer overflow detected" when running SHOW POOL_STATUS Tatsuo Ishii <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: zam bak @ 2025-12-01 14:42 UTC (permalink / raw)
  To: Tatsuo Ishii <[email protected]>; +Cc: [email protected]

On Sat, Nov 29, 2025 at 8:27 PM Tatsuo Ishii <[email protected]> wrote:
>
> Hello,
>
> Thank you for the report!
>
> Unfortunately, I was not able to reproduce the issue on my Ubuntu 24
> and Rocky Linux 10.1 box (pgpool is compiled from source code).
> So there are some questions:
>
> - Is the issue occurred even when you execute other pgpool command?
>   (for example "show pool_processes")

No. Only getting this issue when running SHOW POOL_STATUS

>
> - I found a problem with the output of "show pool_status". The value
>   of "memqcache_stats_start_time" is shown with newline and an empty
>   item followed. I am not sure if this is related to your issue. If
>   possible, can you please try the attached patch?

I suspect you want me to compile it from source (after applying this patch).
I don't have the setup for this unfortunately.
As I mentioned, I did install from RPMs using Rocky Linux 10.1 (with
minimal install option)
Is there a way to provide RPM instead of the patch?


>
> Best regards,
> --
> Tatsuo Ishii
> SRA OSS K.K.
> English: http://www.sraoss.co.jp/index_en/
> Japanese:http://www.sraoss.co.jp
>
> > Hello
> >
> > I am using the latest pgpool-II v4.6.4 on Rocky Linux v10.1
> > (installation via RPMs) with PostgreSQL 18 (one primary, one replica,
> > streaming replication)
> > When attempting to run POOL_STATUS command, either as SQL or via pcp,
> > I am getting "buffer overflow detected" in the log.
> > Here are the contents of the log from both SQL and pcp commands:
> >
> > 1)
> > sudo -u postgres pcp_pool_status -w -v -h localhost -p 9898 -U postgres
> >
> > 2025-11-27 13:30:19.298 [4486]: [3-1] user=[No Connection],db=[No
> > Connection],app=pcp_main LOG:  forked new pcp worker, pid=4495
> > socket=7
> > 2025-11-27 13:30:19.298 [4486]: [4-1] user=[No Connection],db=[No
> > Connection],app=pcp_main LOCATION:  pcp_child.c:327
> > *** buffer overflow detected ***: terminated
> > 2025-11-27 13:30:20.315 [4486]: [5-1] user=[No Connection],db=[No
> > Connection],app=pcp_main LOG:  PCP process with pid: 4495 exits with
> > status 134 by signal 6
> > 2025-11-27 13:30:20.315 [4486]: [6-1] user=[No Connection],db=[No
> > Connection],app=pcp_main LOCATION:  pcp_child.c:394
> >
> > 2)
> > sudo -u postgres psql -w -h localhost -p 9999 -U postgres -c "SHOW POOL_STATUS"
> >
> > 2025-11-27 13:31:34.385 [4390]: [1-1]
> > user=postgres,db=postgres,app=psql LOG:  DB node id: 0 backend pid:
> > 10166 statement: SELECT pg_catalog.version()
> > 2025-11-27 13:31:34.385 [4390]: [2-1]
> > user=postgres,db=postgres,app=psql LOCATION:
> > pool_proto_modules.c:3803
> > *** buffer overflow detected ***: terminated
> >
> >
> >
> > And here is my pgpool.conf file (only changed lines - diff compared to
> > pgpool.conf.sample)
> > diff --unchanged-line-format= --old-line-format=
> > --new-line-format='%L' pgpool.conf.sample pgpool.conf
> >
> > listen_addresses = '*'
> > unix_socket_directories = '/var/run/pgpool'
> > pcp_socket_dir = '/var/run/pgpool'
> > serialize_accept = on
> > backend_hostname0 = '192.168.68.104'
> > backend_port0 = 5432
> > backend_weight0 = 1
> > backend_data_directory0 = '/data/pgdata/18'
> > backend_flag0 = 'ALWAYS_PRIMARY'
> > backend_application_name0 = 'primary'
> > backend_hostname1 = '192.168.68.105'
> > backend_port1 = 5432
> > backend_weight1 = 1
> > backend_data_directory1 = '/data/pgdata/18'
> > backend_flag1 = 'DISALLOW_TO_FAILOVER'
> > backend_application_name1 = 'replica_1'
> > num_init_children = 96
> > max_pool = 2
> > child_life_time = 0
> > log_line_prefix = '%m [%p]: [%l-1] user=%u,db=%d,app=%a '   #
> > printf-style string to output at beginning of each log line.
> > log_connections = off
> > log_disconnections = off
> > log_per_node_statement = on
> > log_standby_delay = 'always'
> > log_error_verbosity = verbose          # terse, default, or verbose messages
> > log_filename = 'pgpool-01-%a.log'
> > write_function_list =
> > 'currval,lastval,nextval,setval,public.upgrade_.*,upgrade_.*,public.update_.*,update_.*,public.selsert_.*,selsert_.*,public.purge_.*,purge_.*,public.process_.*,process_.*,public.move_.*,move_.*,public.merge_.*,merge_.*,public.mark_.*,mark_.*,billing.can_ahs_claim_charge,billing.can_ahs_apply_.*'
> > statement_level_load_balance = on
> > sr_check_period = 5s
> > sr_check_user = 'pgpool_monitor'
> > delay_threshold_by_time = 500ms
> > health_check_period = 10
> > health_check_timeout = 30
> > health_check_user = 'pgpool_monitor'
> > health_check_max_retries = 10
> > failover_on_backend_error = off
> > check_temp_table = trace
> >
> >





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

* Re: "buffer overflow detected" when running SHOW POOL_STATUS
  2025-11-27 18:55 "buffer overflow detected" when running SHOW POOL_STATUS zam bak <[email protected]>
  2025-11-30 01:27 ` Re: "buffer overflow detected" when running SHOW POOL_STATUS Tatsuo Ishii <[email protected]>
  2025-12-01 14:42   ` Re: "buffer overflow detected" when running SHOW POOL_STATUS zam bak <[email protected]>
@ 2025-12-02 05:02     ` Tatsuo Ishii <[email protected]>
  2025-12-02 17:31       ` Re: "buffer overflow detected" when running SHOW POOL_STATUS zam bak <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Tatsuo Ishii @ 2025-12-02 05:02 UTC (permalink / raw)
  To: [email protected]; +Cc: [email protected]

>> Unfortunately, I was not able to reproduce the issue on my Ubuntu 24
>> and Rocky Linux 10.1 box (pgpool is compiled from source code).
>> So there are some questions:
>>
>> - Is the issue occurred even when you execute other pgpool command?
>>   (for example "show pool_processes")
> 
> No. Only getting this issue when running SHOW POOL_STATUS

I found a bug with SHOW POOL_STATUS (and pcp_pool_status). The bug
broke the data segment used for the conversion from binary form of
backend flag (in this case ALWAYS_PRIMARY. Other flag does not raise
the issue) to string representation, which caused the buffer overflow
issue.

Attached is the patch to fix the issue.

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



Attachments:

  [text/x-patch] fix_backend_flag.patch (816B, 2-fix_backend_flag.patch)
  download | inline diff:
diff --git a/src/config/pool_config.l b/src/config/pool_config.l
index b16130293..defedffbd 100644
--- a/src/config/pool_config.l
+++ b/src/config/pool_config.l
@@ -6,7 +6,7 @@
  * pgpool: a language independent connection pool server for PostgreSQL
  * written by Tatsuo Ishii
  *
- * Copyright (c) 2003-2024	PgPool Global Development Group
+ * Copyright (c) 2003-2025	PgPool Global Development Group
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby
@@ -654,7 +654,7 @@ char *pool_flag_to_str(unsigned short flag)
 		if (*buf == '\0')
 			snprintf(buf, sizeof(buf), "ALWAYS_PRIMARY");
 		else
-			snprintf(buf+strlen(buf), sizeof(buf), "|ALWAYS_PRIMARY");
+			strncat(buf, "|ALWAYS_PRIMARY", sizeof(buf));
 	}
 
 	return buf;


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

* Re: "buffer overflow detected" when running SHOW POOL_STATUS
  2025-11-27 18:55 "buffer overflow detected" when running SHOW POOL_STATUS zam bak <[email protected]>
  2025-11-30 01:27 ` Re: "buffer overflow detected" when running SHOW POOL_STATUS Tatsuo Ishii <[email protected]>
  2025-12-01 14:42   ` Re: "buffer overflow detected" when running SHOW POOL_STATUS zam bak <[email protected]>
  2025-12-02 05:02     ` Re: "buffer overflow detected" when running SHOW POOL_STATUS Tatsuo Ishii <[email protected]>
@ 2025-12-02 17:31       ` zam bak <[email protected]>
  2025-12-03 06:29         ` Re: "buffer overflow detected" when running SHOW POOL_STATUS Tatsuo Ishii <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: zam bak @ 2025-12-02 17:31 UTC (permalink / raw)
  To: Tatsuo Ishii <[email protected]>; +Cc: [email protected]

On Tue, Dec 2, 2025 at 12:02 AM Tatsuo Ishii <[email protected]> wrote:
>
> >> Unfortunately, I was not able to reproduce the issue on my Ubuntu 24
> >> and Rocky Linux 10.1 box (pgpool is compiled from source code).
> >> So there are some questions:
> >>
> >> - Is the issue occurred even when you execute other pgpool command?
> >>   (for example "show pool_processes")
> >
> > No. Only getting this issue when running SHOW POOL_STATUS
>
> I found a bug with SHOW POOL_STATUS (and pcp_pool_status). The bug
> broke the data segment used for the conversion from binary form of
> backend flag (in this case ALWAYS_PRIMARY. Other flag does not raise
> the issue) to string representation, which caused the buffer overflow
> issue.
>
> Attached is the patch to fix the issue.

Ishii-san

Thank you for finding the bug and fixing it...

I think this bug warrants a new patch release or a rebuild so we can
use the latest 4.6 in production...
Is it possible to release a new RPM build 4.6.4-2 or 4.6.5?

Regards
Z....


>
> Best regards,
> --
> Tatsuo Ishii
> SRA OSS K.K.
> English: http://www.sraoss.co.jp/index_en/
> Japanese:http://www.sraoss.co.jp
>





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

* Re: "buffer overflow detected" when running SHOW POOL_STATUS
  2025-11-27 18:55 "buffer overflow detected" when running SHOW POOL_STATUS zam bak <[email protected]>
  2025-11-30 01:27 ` Re: "buffer overflow detected" when running SHOW POOL_STATUS Tatsuo Ishii <[email protected]>
  2025-12-01 14:42   ` Re: "buffer overflow detected" when running SHOW POOL_STATUS zam bak <[email protected]>
  2025-12-02 05:02     ` Re: "buffer overflow detected" when running SHOW POOL_STATUS Tatsuo Ishii <[email protected]>
  2025-12-02 17:31       ` Re: "buffer overflow detected" when running SHOW POOL_STATUS zam bak <[email protected]>
@ 2025-12-03 06:29         ` Tatsuo Ishii <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: Tatsuo Ishii @ 2025-12-03 06:29 UTC (permalink / raw)
  To: [email protected]; +Cc: [email protected]; [email protected]

>> I found a bug with SHOW POOL_STATUS (and pcp_pool_status). The bug
>> broke the data segment used for the conversion from binary form of
>> backend flag (in this case ALWAYS_PRIMARY. Other flag does not raise
>> the issue) to string representation, which caused the buffer overflow
>> issue.
>>
>> Attached is the patch to fix the issue.
> 
> Ishii-san
> 
> Thank you for finding the bug and fixing it...
> 
> I think this bug warrants a new patch release or a rebuild so we can
> use the latest 4.6 in production...
> Is it possible to release a new RPM build 4.6.4-2 or 4.6.5?

According to our package manager (Peng Bo), she is planning to release
updated4.6.4 RPM for Rocky Linux 10 later this month.

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






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


end of thread, other threads:[~2025-12-03 06:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-11-27 18:55 "buffer overflow detected" when running SHOW POOL_STATUS zam bak <[email protected]>
2025-11-30 01:27 ` Tatsuo Ishii <[email protected]>
2025-12-01 14:42   ` zam bak <[email protected]>
2025-12-02 05:02     ` Tatsuo Ishii <[email protected]>
2025-12-02 17:31       ` zam bak <[email protected]>
2025-12-03 06:29         ` Tatsuo Ishii <[email protected]>

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