From 1cd5bc3ccf92a511b087629b2c914dffa9151fce Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Wed, 16 Oct 2019 14:51:23 +0200 Subject: Fix crash when reporting CREATE INDEX progress MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A race condition can make us try to dereference a NULL pointer to the PGPROC struct of a process that's already finished. That results in crashes during REINDEX CONCURRENTLY and CREATE INDEX CONCURRENTLY. This was introduced in ab0dfc961b6a, so backpatch to pg12. Reported by: Justin Pryzby Reviewed-by: Michaƫl Paquier Discussion: https://postgr.es/m/20191012004446.GT10470@telsasoft.com --- src/backend/commands/indexcmds.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/backend/commands/indexcmds.c') diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index a5282411310..646b209b2cb 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -384,12 +384,14 @@ WaitForOlderSnapshots(TransactionId limitXmin, bool progress) if (VirtualTransactionIdIsValid(old_snapshots[i])) { + /* If requested, publish who we're going to wait for. */ if (progress) { PGPROC *holder = BackendIdGetProc(old_snapshots[i].backendId); - pgstat_progress_update_param(PROGRESS_WAITFOR_CURRENT_PID, - holder->pid); + if (holder) + pgstat_progress_update_param(PROGRESS_WAITFOR_CURRENT_PID, + holder->pid); } VirtualXactLock(old_snapshots[i], true); } -- cgit v1.2.3