]> granicus.if.org Git - postgresql/commit
Fix volatile-safety issue in asyncQueueReadAllNotifications().
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 26 Jan 2015 16:57:42 +0000 (11:57 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 26 Jan 2015 16:57:42 +0000 (11:57 -0500)
commit5c393a0ac52c46f342f4a11acf8b0d4647cb9da3
tree06cce926ee1f78ccf8a53e128498d6ce8b364d44
parent502e5f9c3608c4620eb3044ad5321d61a1f9f646
Fix volatile-safety issue in asyncQueueReadAllNotifications().

The "pos" variable is modified within PG_TRY and then referenced
within PG_CATCH, so for strict POSIX conformance it must be marked
volatile.  Superficially the code looked safe because pos's address
was taken, which was sufficient to force it into memory ... but it's
not sufficient to ensure that the compiler applies updates exactly
where the program text says to.  The volatility marking has to extend
into a couple of subroutines too, but I think that's probably a good
thing because the risk of out-of-order updates is mostly in those
subroutines not asyncQueueReadAllNotifications() itself.  In principle
the compiler could have re-ordered operations such that an error could
be thrown while "pos" had an incorrect value.

It's unclear how real the risk is here, but for safety back-patch
to all active branches.
src/backend/commands/async.c