Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc58accd

Browse files
committed
Fix volatile-safety issue in asyncQueueReadAllNotifications().
The "pos" variable is modified within PG_TRY and then referencedwithin PG_CATCH, so for strict POSIX conformance it must be markedvolatile. Superficially the code looked safe because pos's addresswas taken, which was sufficient to force it into memory ... but it'snot sufficient to ensure that the compiler applies updates exactlywhere the program text says to. The volatility marking has to extendinto a couple of subroutines too, but I think that's probably a goodthing because the risk of out-of-order updates is mostly in thosesubroutines not asyncQueueReadAllNotifications() itself. In principlethe compiler could have re-ordered operations such that an error couldbe thrown while "pos" had an incorrect value.It's unclear how real the risk is here, but for safety back-patchto all active branches.
1 parentc70f9e8 commitc58accd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

‎src/backend/commands/async.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,13 @@ static void Exec_UnlistenAllCommit(void);
369369
staticboolIsListeningOn(constchar*channel);
370370
staticvoidasyncQueueUnregister(void);
371371
staticboolasyncQueueIsFull(void);
372-
staticboolasyncQueueAdvance(QueuePosition*position,intentryLength);
372+
staticboolasyncQueueAdvance(volatileQueuePosition*position,intentryLength);
373373
staticvoidasyncQueueNotificationToEntry(Notification*n,AsyncQueueEntry*qe);
374374
staticListCell*asyncQueueAddEntries(ListCell*nextNotify);
375375
staticvoidasyncQueueFillWarning(void);
376376
staticboolSignalBackends(void);
377377
staticvoidasyncQueueReadAllNotifications(void);
378-
staticboolasyncQueueProcessPageEntries(QueuePosition*current,
378+
staticboolasyncQueueProcessPageEntries(volatileQueuePosition*current,
379379
QueuePositionstop,
380380
char*page_buffer);
381381
staticvoidasyncQueueAdvanceTail(void);
@@ -1202,7 +1202,7 @@ asyncQueueIsFull(void)
12021202
* returns true, else false.
12031203
*/
12041204
staticbool
1205-
asyncQueueAdvance(QueuePosition*position,intentryLength)
1205+
asyncQueueAdvance(volatileQueuePosition*position,intentryLength)
12061206
{
12071207
intpageno=QUEUE_POS_PAGE(*position);
12081208
intoffset=QUEUE_POS_OFFSET(*position);
@@ -1792,7 +1792,7 @@ DisableNotifyInterrupt(void)
17921792
staticvoid
17931793
asyncQueueReadAllNotifications(void)
17941794
{
1795-
QueuePositionpos;
1795+
volatileQueuePositionpos;
17961796
QueuePositionoldpos;
17971797
QueuePositionhead;
17981798
booladvanceTail;
@@ -1952,7 +1952,7 @@ asyncQueueReadAllNotifications(void)
19521952
* The QueuePosition *current is advanced past all processed messages.
19531953
*/
19541954
staticbool
1955-
asyncQueueProcessPageEntries(QueuePosition*current,
1955+
asyncQueueProcessPageEntries(volatileQueuePosition*current,
19561956
QueuePositionstop,
19571957
char*page_buffer)
19581958
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp