Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qkdgj-00FMUl-Uk for pgsql-bugs@arkaria.postgresql.org; Mon, 25 Sep 2023 04:59:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qkdgh-00EzHd-KM for pgsql-bugs@arkaria.postgresql.org; Mon, 25 Sep 2023 04:59:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qkdgh-00EzHP-AP for pgsql-bugs@lists.postgresql.org; Mon, 25 Sep 2023 04:59:15 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qkdge-006UDH-LM for pgsql-bugs@lists.postgresql.org; Mon, 25 Sep 2023 04:59:14 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 38P4x9RD086522; Mon, 25 Sep 2023 00:59:09 -0400 From: Tom Lane To: Thomas Munro cc: Michael Paquier , Alexander Lakhin , Sergei Kornilov , Noah Misch , Kyotaro Horiguchi , pgsql-bugs@lists.postgresql.org, Fujii Masao , pgbf@twiska.com Subject: Re: BUG #17928: Standby fails to decode WAL on termination of primary In-reply-to: References: <64446.1695611228@sss.pgh.pa.us> Comments: In-reply-to Thomas Munro message dated "Mon, 25 Sep 2023 16:47:12 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <86520.1695617949.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 25 Sep 2023 00:59:09 -0400 Message-ID: <86521.1695617949@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thomas Munro writes: > On Mon, Sep 25, 2023 at 4:07=E2=80=AFPM Tom Lane wro= te: >> That one is mine, so let me know if there's something particular >> you'd like me to check. > Thanks! But after spending the best part of a day installing and > compiling stuff at snail's pace, I have just this moment managed to > reproduce this reliably on an emulator running Debian armhf (=3D armv7). > So hopefully I can track the issue down from here without bothering > build farm owners. FWIW, here's what I see on mamba: Program terminated with signal SIGSEGV, Segmentation fault. #0 pg_comp_crc32c_sb8 (crc=3D3197562372, crc@entry=3D4294967295, = data=3Ddata@entry=3D0xfda6e030, len=3D) at pg_crc32c_sb= 8.c:56 56 uint32 a =3D *p4++ ^ crc; (gdb) bt #0 pg_comp_crc32c_sb8 (crc=3D3197562372, crc@entry=3D4294967295, = data=3Ddata@entry=3D0xfda6e030, len=3D) at pg_crc32c_sb= 8.c:56 #1 0x0195ae5c in ValidXLogRecord (state=3D0xfde5cc88, record=3D0xfda6e018= , = recptr=3D) at xlogreader.c:1195 #2 0x0195cf18 in XLogDecodeNextRecord (state=3Dstate@entry=3D0xfde5cc88, = nonblocking=3D) at xlogreader.c:842 #3 0x0195d0c8 in XLogReadAhead (state=3D0xfde5cc88, = nonblocking=3Dnonblocking@entry=3Dfalse) at xlogreader.c:969 #4 0x01959760 in XLogPrefetcherNextBlock (pgsr_private=3D4259700408, = lsn=3D0xfda6b8a0) at xlogprefetcher.c:496 #5 0x0195a72c in lrq_prefetch (lrq=3D) at xlogprefetcher.c= :256 #6 lrq_complete_lsn (lsn=3D50520048, lrq=3D0xfda6b858) at xlogprefetcher.= c:294 #7 XLogPrefetcherReadRecord (prefetcher=3Dprefetcher@entry=3D0xfde5deb8, = errmsg=3Derrmsg@entry=3D0xffffdd88) at xlogprefetcher.c:1041 #8 0x01960054 in ReadRecord (xlogprefetcher=3D0xfde5deb8, emode=3Demode@e= ntry=3D15, = fetching_ckpt=3Dfetching_ckpt@entry=3Dfalse, replayTLI=3DreplayTLI@ent= ry=3D3) at xlogrecovery.c:3067 #9 0x01963188 in PerformWalRecovery () at xlogrecovery.c:1756 #10 0x01952594 in StartupXLOG () at xlog.c:5470 #11 0x01c26e3c in StartupProcessMain () at startup.c:267 #12 0x01c1b504 in AuxiliaryProcessMain (auxtype=3Dauxtype@entry=3DStartupP= rocess) at auxprocess.c:141 #13 0x01c2276c in StartChildProcess (type=3DStartupProcess) at postmaster.= c:5347 #14 0x01c260ec in PostmasterMain (argc=3Dargc@entry=3D4, = argv=3Dargv@entry=3D0xffffe1e4) at postmaster.c:1457 #15 0x01ee39d8 in main (argc=3D4, argv=3D0xffffe1e4) at main.c:198 (gdb) f 1 #1 0x0195ae5c in ValidXLogRecord (state=3D0xfde5cc88, record=3D0xfda6e018= , = recptr=3D) at xlogreader.c:1195 1195 COMP_CRC32C(crc, ((char *) record) + SizeOfXLogRecord, rec= ord->xl_tot_len - SizeOfXLogRecord); (gdb) p *record $3 =3D {xl_tot_len =3D 0, xl_xid =3D 0, xl_prev =3D 0, xl_info =3D 0 '\000= ', = xl_rmid =3D 0 '\000', xl_crc =3D 0} Sure looks like ValidXLogRecord is assuming that record->xl_tot_len can be trusted without reservation. regards, tom lane