postgresql/src/backend/tcop
Tom Lane 48582cf9ed Be more rigorous about local variables in PostgresMain().
Since PostgresMain calls sigsetjmp, any local variables that are not
marked "volatile" have a risk of unspecified behavior.  In practice
this means that when control returns via longjmp, such variables might
get reset to their values as of the time of sigsetjmp, depending on
whether the compiler chose to put them in registers or on the stack.
We were careful about this for "send_ready_for_query", but not the
other local variables.

In the case of the timeout_enabled flags, resetting them to
their initial "false" states is actually good, since we do
"disable_all_timeouts()" in the longjmp cleanup code path.  If that
does not happen, we risk uselessly calling "disable_timeout()" later,
which is harmless but a little bit expensive.  Let's explicitly reset
these flags so that the behavior is correct and platform-independent.
(This change means that we really don't need the new "volatile"
markings after all, but let's install them anyway since any change
in this logic could re-introduce a problem.)

There is no issue for "firstchar" and "input_message" because those
are explicitly reinitialized each time through the query processing
loop.  To make that clearer, move them to be declared inside the loop.
That leaves us with all the function-lifespan locals except the
sigjmp_buf itself marked as volatile, which seems like a good policy
to have going forward.

Because of the possibility of extra disable_timeout() calls, this
seems worth back-patching.

Sergey Shinderuk and Tom Lane

Discussion: https://postgr.es/m/2eda015b-7dff-47fd-d5e2-f1a9899b90a6@postgrespro.ru
2023-07-10 12:14:34 -04:00
..
Makefile Represent command completion tags as structs 2020-03-02 18:19:51 -03:00
cmdtag.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
dest.c Remove server and libpq support for old FE/BE protocol version 2. 2021-03-04 10:45:55 +02:00
fastpath.c Message style improvements 2021-06-28 08:36:44 +02:00
postgres.c Be more rigorous about local variables in PostgresMain(). 2023-07-10 12:14:34 -04:00
pquery.c Fix Portal snapshot tracking to handle subtransactions properly. 2021-10-01 11:10:12 -04:00
utility.c Fix DDL deparse of CREATE OPERATOR CLASS 2022-05-20 18:52:55 +02:00