Re: Adding volatile qualifer

From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: pgpool-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Adding volatile qualifer
Date: 2026-07-03 11:24:23
Message-ID: 20260703.202423.640416716760511415.ishii@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgpool-hackers

> While looking into the Pgpool-II main source code, I noticed that
> local pointer array "my_backend_status" is not volatile qualified,
> while it should have been.
>
> BACKEND_STATUS *my_backend_status[MAX_NUM_BACKENDS]; /* Backend status buffer */
>
> This array members are initialized:
>
> for (i = 0; i < MAX_NUM_BACKENDS; i++)
> {
> my_backend_status[i] = &(BACKEND_INFO(i).backend_status);
> }
>
> Without volatile, *(my_backend_status[i]) could read state value
> because of compiler optimization. Since my_backend_status[i] is
> referred to in popular VALID_BACKEND macro, we should fix it in all
> supported branches.

volatile qualifier should have been attached to the right hand side
too. Attached v2 patch does it.

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

Attachment Content-Type Size
failover_fix_v2.patch text/x-patch 2.1 KB

In response to

Browse pgpool-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2026-07-07 22:19:42 Re: Reject sub-minimum ErrorResponse length in read_kind_from_backend.
Previous Message Emond Papegaaij 2026-07-03 07:22:34 Re: [PATCH] Segfault in pool_do_auth() when failover races with a new connection