From cfa141f42ea3cef312e16013c0f43e44f0d647ba Mon Sep 17 00:00:00 2001 From: Xing Guo Date: Thu, 23 May 2024 14:38:02 +0800 Subject: [PATCH] Add missing volatile qualifier. (#17521) According to C99 7.13.2.1[^1], > All accessible objects have values, and all other components of the abstract machine have state, as of the time the longjmp function was called, except that the values of objects of automatic storage duration that are local to the function containing the invocation of the corresponding setjmp macro that do not have volatile-qualified type and have been changed between the setjmp invocation and longjmp call are indeterminate. The object oldcontext is changed in line 1194 (inside PG_TRY() block) and read in line 1434 (inside PG_CATCH() block). We should qualify it with volatile. [^1]: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf --- src/backend/executor/nodeSubplan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/executor/nodeSubplan.c b/src/backend/executor/nodeSubplan.c index 14980f86e5e..4800300a670 100644 --- a/src/backend/executor/nodeSubplan.c +++ b/src/backend/executor/nodeSubplan.c @@ -1107,7 +1107,7 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext, QueryDesc *queryDesc SubLinkType subLinkType = subplan->subLinkType; EState *estate = planstate->state; ScanDirection dir = estate->es_direction; - MemoryContext oldcontext = NULL; + volatile MemoryContext oldcontext = NULL; TupleTableSlot *slot; ListCell *pvar; ListCell *l;