Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ndxEA-0008Mi-Qz for pgsql-bugs@arkaria.postgresql.org; Mon, 11 Apr 2022 16:49:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ndxE9-0008Jg-8B for pgsql-bugs@arkaria.postgresql.org; Mon, 11 Apr 2022 16:49:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ndxE9-0008JR-0L for pgsql-bugs@lists.postgresql.org; Mon, 11 Apr 2022 16:49:21 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ndxE6-0003OY-Lz for pgsql-bugs@lists.postgresql.org; Mon, 11 Apr 2022 16:49:19 +0000 Received: by mail-ed1-x532.google.com with SMTP id w18so19164368edi.13 for ; Mon, 11 Apr 2022 09:49:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bowt-ie.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TyIDJ3Tm8hvgVOPyDqgM7ulK2qVJaZsKxHuf/layC/8=; b=HBBw/KEogYLA595lHYKLvef/EqyJzAwQQwFYHVXxBr9uoq7oNSMTcNtGrTq5heCp/z r0L5zLZWqfwvNflmwmIBxVWd/k7DkZijRO5Q7R63tMfgl1Lx5YsPHSRbr1a72IpE9tAo YISdnOQVkTBwyXObNssg1lMsqyJvod4m3h7KjZnRmvqOFJ6kqofUwJCNanhRG3XjRhet deZaBqZ4zwFzRQLMP9VRMQ8KG9A44bAFfWd61TpUycR4Isn43PIaTZVftoxhMymBgDh+ kImzMhcu46+GYpHbIeVWa6ixTdh9biIYFaVyhDbzjgt6TOioheE+noElhRSLTN7sXGbv AwxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TyIDJ3Tm8hvgVOPyDqgM7ulK2qVJaZsKxHuf/layC/8=; b=8NGrxPTwXEqE6veXNCXZoFlnLlW5+EX+QXYvV5nOXk0PMqkcEs4+akCHOIqTHmXThY L1amDPWQPtqp4nk3jxXvdZPaZNqZX1HpDPwx2DVsbpNkDhYGqhpWFd86IzvDDTHy7Ubz g2yYVq8cbm1CS5l0vcTgbVpNaCnyYR23NXkp37+v6e6JaoNMei0yUVCvN8ymsuXoXYNO 1q9cT05IcCMDAX+P8/OkcXduJUyb6l1eRO/NyvZDnkma0vpUJx1eu5zK/09o6x3PhpXm wUwTsWwdF6Qjd3L6a7w+fEugLyJsO3+MjBCoen6ZwLrG1rGUuepL1poGnEljz9xgyXEA ICgw== X-Gm-Message-State: AOAM5303hqmesDz0q6n6QQoIcONSwI9Wi2RwRrg5WJJESu4WmP3QsIpM Ymxw+Fd8JoPSY3UutKMooOobJEThe+DmMquMdYyFbg== X-Google-Smtp-Source: ABdhPJxak7+OBXTj5s27w3edOA7czLyqn4ICkWfFUogQ5vkb6SjujzDPZmAuHYAS+IlHKT3XlY8PVsqaCq2ATpKiNXo= X-Received: by 2002:a05:6402:14b:b0:418:d06e:5d38 with SMTP id s11-20020a056402014b00b00418d06e5d38mr33426019edu.90.1649695757397; Mon, 11 Apr 2022 09:49:17 -0700 (PDT) MIME-Version: 1.0 References: <17462-9c98a0f00df9bd36@postgresql.org> <286748.1649692519@sss.pgh.pa.us> <290412.1649694952@sss.pgh.pa.us> In-Reply-To: <290412.1649694952@sss.pgh.pa.us> From: Peter Geoghegan Date: Mon, 11 Apr 2022 09:48:51 -0700 Message-ID: Subject: Re: BUG #17462: Invalid memory access in heapam_tuple_lock To: Tom Lane Cc: anisimow.d@gmail.com, PostgreSQL mailing lists Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Apr 11, 2022 at 9:35 AM Tom Lane wrote: > > The other backend's page defragmentation step (from pruning) > > would render our backend's HeapTuple pointer invalid. Presumably it > > would just look like an invalid/non-matching xmin in our backend, at > > the point of control flow that Valgrind complains about > > (heapam_handler.c:509). > > Right, but there are other accesses below, and in any case match > failure isn't necessarily the right thing. That's what I meant -- it very likely would have been a match if the same scenario played out, but without any concurrent pruning. With a concurrent prune, xmin won't ever be a match (barring a near-miraculous coincidence). That behavior is definitely wrong, but also quite subtle (compared to what might happen if we got past the xmin/xmax check). I think that that explains why it took this long to notice the bug. -- Peter Geoghegan