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.96) (envelope-from ) id 1wF6sF-004ko0-0E for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Apr 2026 08:54:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wF6sE-007pKQ-0y for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Apr 2026 08:54:26 +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.96) (envelope-from ) id 1wF6sE-007pJt-04 for pgsql-hackers@lists.postgresql.org; Tue, 21 Apr 2026 08:54:26 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wF6sB-00000002Gus-42uB for pgsql-hackers@lists.postgresql.org; Tue, 21 Apr 2026 08:54:25 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-48984d29fe3so22793495e9.0 for ; Tue, 21 Apr 2026 01:54:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776761663; x=1777366463; darn=lists.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=vYleDMg4w+HTTgbFKDyJQuPjDxKm7h6UUD9E70tkFCA=; b=VMC838K3ycFgg9ecWEiloXi+Dvwk++UPV0pt7QH80jToijCztIYWx+NxDzMJeJgOKt QAPq+IHft2neDzzqloE/9f6mTcaZEWA9bD/WhvZCmoHmnMP6YVr5v1FsTRhM87lEQ/fu qDr7r18Lr86kuV9lmWIuYGk/0hthd35ty8g/6b6ykv2OPgcQuLgIuupJmZ0+SRqX6pVS CFYNGOwiRvunW28782PBYMtGei+wXSQkFmw7YpzVt4veAwW78C8qq4SKEEFHJAjxt3cl T68MGBCCTCjlpKbUMcLGMJGP6FdOsKeqsXQ4idPIPbGwtjuRUwTvsFhi5WHwrbDg8G4v enkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776761663; x=1777366463; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vYleDMg4w+HTTgbFKDyJQuPjDxKm7h6UUD9E70tkFCA=; b=UZ5dvGqZHDbySGm6wbkzewZ/uXfIRxGVCErvDryNWddbs8Ft0T9ZK61ADvCira37DK sDeKKTUI5m/mRg0K8uB2afLSHEqXCP3bUc2smkIsu4bhLfoobfFHxuZXd0L7RwsMYiXq vb4VnIMKomqdObOHD4gk+NRHFlcmgzqjkpNXXilE9uBVuT71u6KEjr16pWMZzDmJYHuA oNHrg/rb3YPLTwjWEo7xYQm19hWj2cmYT82UkK8nKShqMVl1pZWMwhjH7Vllrs6tHKQo w9eEaRgRlES3pxpmU3vHL8V5EZO+jk3XyUzvHBRkFh0Oj9QLKNcoQoYtbB65oF+AErap OFNQ== X-Gm-Message-State: AOJu0YxseUzepntKsxXnXPi6P9sAJqb89he075NKXbNB5rZV3t7eY90B bONt2LOovNadCtEnmuQnWSltu9lz6mSlP6MWrfCN9LZFZnHSkuj4o7a4 X-Gm-Gg: AeBDieubvBYDmFBTT4EwHsfXEYl4zWfNmu/HUv3PHTFIfINQhvYeNhlhFl7hqpyYMlN pPYSzw3t5Rd0asvoHQcjdxSmVoo+dXmXWiMD3JDwqtBggrq5efFxNfz2n08A2S0WvzYj51LCpBY JRBMDET5YZ6mTAjhjO1KJPD7DJ4NYsX1a8BpxsfvrbqmSBXiFVOscCHLuc0RQPVwe0recA2UgQ6 SOgPGI3I3DS1YHhPijAa/Ik/WhK1a9DX5drcfq7e9Qr49DDM23pGZ7arCBGMytuF1nJR32UgFTO /qJR9eKZQELrBlGwasgnnix/x85lIBOsTNtif/QpefE3iTcwcX7LCa7cpKqAW9FMMcp9KufFDxX MWukohOgaESGjUNW0wxWtZAWA11/cU+vSXdkHHUEYaFCrfL/OmJ0xwpQBQSS3F9nU2gbPIKW88D 9nGqA6f8OYZ9TEuAG6Cr8iTvQZ7FTYnjOyF2wK3EhYbirtqs09uXldmzZLp2YtJI49gREArRttF wpitCC79g== X-Received: by 2002:a05:600c:c090:b0:488:9e54:94c0 with SMTP id 5b1f17b1804b1-488fb74e130mr176053745e9.8.1776761662538; Tue, 21 Apr 2026 01:54:22 -0700 (PDT) Received: from [192.168.0.86] (84.123.230.95.dyn.user.ono.com. [84.123.230.95]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4891c318636sm150435415e9.7.2026.04.21.01.54.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Apr 2026 01:54:22 -0700 (PDT) Message-ID: <1b67f95c-27a5-42dd-8c95-efe452094dc3@gmail.com> Date: Tue, 21 Apr 2026 10:54:21 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: A very quick observation of dangling pointers in Postgres pathlists To: David Rowley Cc: PostgreSQL Hackers , Tom Lane , "a.rybakina" References: <20be3d9d-4147-492a-b69c-d69a87a014a9@gmail.com> Content-Language: en-US From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 21/04/2026 10:35, David Rowley wrote: > On Tue, 21 Apr 2026 at 19:29, Andrei Lepikhov wrote: >> I've attached a patch that shows how to fix the issue. Some regression tests >> change because of a hidden rule where a projection and its subpath have >> different target lists. Right now, the patch always enforces a projection, even >> if the target lists are the same. This is still open for discussion on whether >> there's a better way to handle it. > > IMO, we should write a function like copy_path() or reparent_path(), > which creates a copy of the given Path, or the latter also would copy > then set the ->parent to the given RelOptInfo. Any time we use a path > directly from the pathlist of another RelOptInfo, we should reparent > or copy it. We could add an Assert in add_path() to check the new path > has the correct parent to help us find the places where we forget to > do this. It would be great to have a copy_path() function. At the moment, I create a limited version each time in an extension module, using reparameterize_path_by_child as a guide since it ensures the core can handle path copies. Do you mean we can introduce such a copy routine to fix current issue? Here is the problem: dangling pointers are detected only by external tools. I can't imagine an SQL reproducer to test this machinery. -- regards, Andrei Lepikhov, pgEdge