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

Commit03a37e9

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 parentb00a088 commit03a37e9

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
@@ -371,13 +371,13 @@ static void Exec_UnlistenAllCommit(void);
371371
staticboolIsListeningOn(constchar*channel);
372372
staticvoidasyncQueueUnregister(void);
373373
staticboolasyncQueueIsFull(void);
374-
staticboolasyncQueueAdvance(QueuePosition*position,intentryLength);
374+
staticboolasyncQueueAdvance(volatileQueuePosition*position,intentryLength);
375375
staticvoidasyncQueueNotificationToEntry(Notification*n,AsyncQueueEntry*qe);
376376
staticListCell*asyncQueueAddEntries(ListCell*nextNotify);
377377
staticvoidasyncQueueFillWarning(void);
378378
staticboolSignalBackends(void);
379379
staticvoidasyncQueueReadAllNotifications(void);
380-
staticboolasyncQueueProcessPageEntries(QueuePosition*current,
380+
staticboolasyncQueueProcessPageEntries(volatileQueuePosition*current,
381381
QueuePositionstop,
382382
char*page_buffer);
383383
staticvoidasyncQueueAdvanceTail(void);
@@ -1225,7 +1225,7 @@ asyncQueueIsFull(void)
12251225
* returns true, else false.
12261226
*/
12271227
staticbool
1228-
asyncQueueAdvance(QueuePosition*position,intentryLength)
1228+
asyncQueueAdvance(volatileQueuePosition*position,intentryLength)
12291229
{
12301230
intpageno=QUEUE_POS_PAGE(*position);
12311231
intoffset=QUEUE_POS_OFFSET(*position);
@@ -1815,7 +1815,7 @@ DisableNotifyInterrupt(void)
18151815
staticvoid
18161816
asyncQueueReadAllNotifications(void)
18171817
{
1818-
QueuePositionpos;
1818+
volatileQueuePositionpos;
18191819
QueuePositionoldpos;
18201820
QueuePositionhead;
18211821
booladvanceTail;
@@ -1975,7 +1975,7 @@ asyncQueueReadAllNotifications(void)
19751975
* The QueuePosition *current is advanced past all processed messages.
19761976
*/
19771977
staticbool
1978-
asyncQueueProcessPageEntries(QueuePosition*current,
1978+
asyncQueueProcessPageEntries(volatileQueuePosition*current,
19791979
QueuePositionstop,
19801980
char*page_buffer)
19811981
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp