From: Fujii Masao Date: Wed, 4 Nov 2020 12:49:00 +0000 (+0900) Subject: Fix segmentation fault that commit ac22929a26 caused. X-Git-Tag: REL_14_BETA1~1352 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=113d3591b859fb8dc191bc0599d1ad62d91f1aa4;p=postgresql.git Fix segmentation fault that commit ac22929a26 caused. Commit ac22929a26 changed recoveryWakeupLatch so that it's reset to NULL at the end of recovery. This change could cause a segmentation fault in the buildfarm member 'elver'. Previously the latch was reset to NULL after calling ShutdownWalRcv(). But there could be a window between ShutdownWalRcv() and the actual exit of walreceiver. If walreceiver set the latch during that window, the segmentation fault could happen. To fix the issue, this commit changes walreceiver so that it sets the latch only when the latch has not been reset to NULL yet. Author: Fujii Masao Discussion: https://postgr.es/m/5c1f8a85-747c-7bf9-241e-dd467d8a3586@iki.fi --- diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index e081bf92608..a1078a7cfca 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -12673,7 +12673,8 @@ CheckPromoteSignal(void) void WakeupRecovery(void) { - SetLatch(XLogCtl->recoveryWakeupLatch); + if (XLogCtl->recoveryWakeupLatch) + SetLatch(XLogCtl->recoveryWakeupLatch); } /*