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 1r8M3u-009SOH-48 for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Nov 2023 15:01:14 +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 1r8M3s-00BGxc-Qy for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Nov 2023 15:01:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r8M2s-00BEd7-Ja for pgsql-hackers@lists.postgresql.org; Wed, 29 Nov 2023 15:00:10 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1r8M2p-009Bhy-G3 for pgsql-hackers@postgresql.org; Wed, 29 Nov 2023 15:00:10 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-50bc4fe8158so1117241e87.0 for ; Wed, 29 Nov 2023 07:00:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701270006; x=1701874806; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ggOa2pgJWR9lsksAwdGnGpmeJWK67ACjWgNZOXCjN3o=; b=iids6gRaFzAO80Cd7JjcBG4imQwWeZtBYv4tHq+50oGBS0bNLokR515efJsFLQMXW/ TDXDVMtTd2cEp0KYlUrBthkv8/6D+r23+8ZRyPncN2EHWAR9Z77C+/lZgkh43M1QD8Nf l4YJ5FB0yUi9qVYre1w8wmoh7H10xebI00G4iMyB/kjD8rRRdPcaCMYnddSVltLUGeyz p/gEw/LUj4aNXbMuJB8iN45MVdHNrwROsiwMZbfhZv4+pP2ciM5COYh6LstdcQaYpWpS DROgiHwGo/LQmbiPUF2KqxDaQFPTxr7FWt38RF9b7vZzePbpNXpazy1f6znppeLrOWoV ZvQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701270006; x=1701874806; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ggOa2pgJWR9lsksAwdGnGpmeJWK67ACjWgNZOXCjN3o=; b=hGVy9nGgxk5CQM/gqw0Ll3QWfzqTTNsJfxU77IbaPeUMH3oRrjQ96EXyYducnbAGA5 AgYyt26TERoTYHebKs+qM7hIO6jZ9aWbjDUHXlgN73nj/uIlDLsLtK9mjq8UA9dDKzFt 0WbM3xBpg9UxffmtzE8+iIACy0bVVxAtsF0l51jSOi5njBUPqFQ1hbpmIc+Nb8yKtdq7 8MQLwyrYkqifhFycqb6hv+NfMmiIHu2V8U8exuEPi1ofdLxbxw/zv1Jyu76gWU0fAj9B h/AUq46Tn0lc5zRG2tfRR9F4FJhi+OIGJOrZpT1bwqFnETidqhduIVlWR/OsxUBa7/mK ++jg== X-Gm-Message-State: AOJu0YwQI2rToYutCnn1Aip7qMgL4Mpy5AoSGFRQRH+BHgf4/w7CITku 4zPhwlrLBWCzOUC2h6hmEZY= X-Google-Smtp-Source: AGHT+IGqhuESfls84FdUOT8ffsli1sm6yK8XgDvtc8LAtVfH96Qipl1941DWpe8cWTpLEva4Ve4oYw== X-Received: by 2002:a19:751a:0:b0:50b:c21c:258a with SMTP id y26-20020a19751a000000b0050bc21c258amr1858197lfe.11.1701270006222; Wed, 29 Nov 2023 07:00:06 -0800 (PST) Received: from [1.0.0.7] ([178.155.22.198]) by smtp.gmail.com with ESMTPSA id f17-20020a05651232d100b0050aa6bd6d8csm2197741lfg.178.2023.11.29.07.00.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Nov 2023 07:00:05 -0800 (PST) Message-ID: <62ed1a9f-746a-8e86-904b-51b9b806a1d9@gmail.com> Date: Wed, 29 Nov 2023 18:00:01 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: Is this a problem in GenericXLogFinish()? To: Amit Kapila , "Hayato Kuroda (Fujitsu)" Cc: Michael Paquier , Robert Haas , Jeff Davis , Heikki Linnakangas , "pgsql-hackers@postgresql.org" References: Content-Language: en-US From: Alexander Lakhin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello, 13.11.2023 20:21, Robert Haas wrote: > On Mon, Nov 13, 2023 at 12:47 AM Hayato Kuroda (Fujitsu) > wrote: >> Moved. > I see that this patch was committed, but I'm not very convinced that > the approach is correct. The comment says this: > I've discovered that that patch introduced a code path leading to an uninitialized memory access. With the following addition to hash_index.sql:  -- Fill overflow pages by "dead" tuples.  BEGIN;  INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 1000) as i; +INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 1000) as i;  ROLLBACK; +INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 1000) as i; make check -C src/test/recovery/ PROVE_TESTS="t/027*" when executed under Valgrind, triggers: ==00:00:02:30.285 97744== Conditional jump or move depends on uninitialised value(s) ==00:00:02:30.285 97744==    at 0x227585: BufferIsValid (bufmgr.h:303) ==00:00:02:30.285 97744==    by 0x227585: hash_xlog_squeeze_page (hash_xlog.c:781) ==00:00:02:30.285 97744==    by 0x228133: hash_redo (hash_xlog.c:1083) ==00:00:02:30.285 97744==    by 0x2C2801: ApplyWalRecord (xlogrecovery.c:1943) ==00:00:02:30.285 97744==    by 0x2C5C52: PerformWalRecovery (xlogrecovery.c:1774) ==00:00:02:30.285 97744==    by 0x2B63A1: StartupXLOG (xlog.c:5559) ==00:00:02:30.285 97744==    by 0x558165: StartupProcessMain (startup.c:282) ==00:00:02:30.285 97744==    by 0x54DFE8: AuxiliaryProcessMain (auxprocess.c:141) ==00:00:02:30.285 97744==    by 0x5546B0: StartChildProcess (postmaster.c:5331) ==00:00:02:30.285 97744==    by 0x557A53: PostmasterMain (postmaster.c:1458) ==00:00:02:30.285 97744==    by 0x4720C2: main (main.c:198) ==00:00:02:30.285 97744== (in 027_stream_regress_standby_1.log) That is, when line https://coverage.postgresql.org/src/backend/access/hash/hash_xlog.c.gcov.html#661 is reached, writebuf stays uninitialized. Best regards, Alexander