]> granicus.if.org Git - postgresql/commit
Fix reference-after-free when waiting for another xact due to constraint.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 4 Feb 2015 14:00:34 +0000 (16:00 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 4 Feb 2015 14:07:27 +0000 (16:07 +0200)
commit48a565d78ba9413317d6095010cf622e9d6a36eb
treea7f0d4adcd2a7e79ea8e5772049d28d5b8a8d0af
parent742734d2b54005f228655f0733e869b16ec6cb2b
Fix reference-after-free when waiting for another xact due to constraint.

If an insertion or update had to wait for another transaction to finish,
because there was another insertion with conflicting key in progress,
we would pass a just-free'd item pointer to XactLockTableWait().

All calls to XactLockTableWait() and MultiXactIdWait() had similar issues.
Some passed a pointer to a buffer in the buffer cache, after already
releasing the lock. The call in EvalPlanQualFetch had already released the
pin too. All but the call in execUtils.c would merely lead to reporting a
bogus ctid, however (or an assertion failure, if enabled).

All the callers that passed HeapTuple->t_data->t_ctid were slightly bogus
anyway: if the tuple was updated (again) in the same transaction, its ctid
field would point to the next tuple in the chain, not the tuple itself.

Backpatch to 9.4, where the 'ctid' argument to XactLockTableWait was added
(in commit f88d4cfc)
src/backend/access/heap/heapam.c
src/backend/catalog/index.c
src/backend/executor/execMain.c
src/backend/executor/execUtils.c