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

Commit6ae1513

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 parent7240f92 commit6ae1513

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);
@@ -1204,7 +1204,7 @@ asyncQueueIsFull(void)
12041204
* returns true, else false.
12051205
*/
12061206
staticbool
1207-
asyncQueueAdvance(QueuePosition*position,intentryLength)
1207+
asyncQueueAdvance(volatileQueuePosition*position,intentryLength)
12081208
{
12091209
intpageno=QUEUE_POS_PAGE(*position);
12101210
intoffset=QUEUE_POS_OFFSET(*position);
@@ -1794,7 +1794,7 @@ DisableNotifyInterrupt(void)
17941794
staticvoid
17951795
asyncQueueReadAllNotifications(void)
17961796
{
1797-
QueuePositionpos;
1797+
volatileQueuePositionpos;
17981798
QueuePositionoldpos;
17991799
QueuePositionhead;
18001800
booladvanceTail;
@@ -1954,7 +1954,7 @@ asyncQueueReadAllNotifications(void)
19541954
* The QueuePosition *current is advanced past all processed messages.
19551955
*/
19561956
staticbool
1957-
asyncQueueProcessPageEntries(QueuePosition*current,
1957+
asyncQueueProcessPageEntries(volatileQueuePosition*current,
19581958
QueuePositionstop,
19591959
char*page_buffer)
19601960
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp