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 1wPkzu-0010M8-2h for pgsql-bugs@arkaria.postgresql.org; Wed, 20 May 2026 17:46:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wPkzr-008DBx-1N for pgsql-bugs@arkaria.postgresql.org; Wed, 20 May 2026 17:46:20 +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 1wPkzr-008DBp-0d for pgsql-bugs@lists.postgresql.org; Wed, 20 May 2026 17:46:20 +0000 Received: from mail-dl1-x1236.google.com ([2607:f8b0:4864:20::1236]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wPkzq-00000000aRI-16ng for pgsql-bugs@lists.postgresql.org; Wed, 20 May 2026 17:46:19 +0000 Received: by mail-dl1-x1236.google.com with SMTP id a92af1059eb24-12c19d23b19so7082018c88.0 for ; Wed, 20 May 2026 10:46:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1779299175; cv=none; d=google.com; s=arc-20240605; b=C1LzGcitGUfdxuatrOZlcYxJ6vhtTrKa8pd0tP6NQLJdb1tdpGMiKajfhMeaCzG6r+ b7qy/Dj7DanxyopHAqbV27plQTFoST3KYc19uNYEwr0W93p5pXKxR9W07w/k6eKi4cBj uoxnP8COou/spB6nMfj4+6lbE3qqqCAV9CHAY4261NcbfxbNEWILniHoetTlsGLUmV2F H3XkMkapHr9HYldmbpDOT0bk0AC4CVy4xwSmrTw4W3RUsefCv1L0YAs+5lGzYOXlkqxO Qh8dIRSMHtgGs10pL1xqP3zCKEkBWoNc+I4TMrt4HKJPIHpmZcfyxoWKAO6PEe1uwkMX Fi5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Gw/ipQVPksgWoEAycGwn3lKHlvRLcLdcdo1cJCGa+ug=; fh=PVVDlfS6/tt48gw50SVjVD0KNXRXXXXDFqdPm2LQNRg=; b=MJgWYORsdYpWiynpMVg9clVhwzKqiH5nk2vYXCgIL2kBrxa/0Z81gTo3heJAcXEMdX xwNRAid/dgEuijplGD8CbER8t6YmWDy3EvQJuMDBayvEylJc1+ig4Fz+OoR8bDszbsbE xcBTnJGuMxF5Nfcv37Ocmam2pQZPt34Pj1cgZbq4ei/XOVW37WZg6P6GJx6RQnhkRL8O 1vzmP2SdrM1gZ9gYcY5GwfTrdjM319+880rsYJEmKVQ0hzFShO7GU09x3g3txRvLwcVT o9tIQKht3aZ1Ow4te/Z3VgzJmDsy5Ntthh4oTCRsGrPHqPiBYPz7jUFHgskzr+dhvdJw K7YA==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779299175; x=1779903975; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Gw/ipQVPksgWoEAycGwn3lKHlvRLcLdcdo1cJCGa+ug=; b=HXzLrR18TY7qpnLvJPudCVozCsl22hFMTGUIowwd5dPLbE4drLlJ/+VWypreJYXt4Q +t25DfX2IGWMzdfDPrJI5gubcyb4SL+FyaWHskNwJGacbdlj6gQmZx0dVKbrO3l/TFdG L78q4GrH0U8Q91R/WN7sH7NaDlLw9CNc7pMko7JepLV6wnAlr1A1ox7kgVg9TNJj/qRE OeA1JqQpRpmKgkpnhMUKo9g/VRNWrtv2O0EW8kRlaL9QPl71/l+Uw9NiV46tZbayy0aC ycs9RQO+MAYEBW5creN582nR7cIIozftWSmkqc+I67vWARnaK+noqnVVlJt7PzLiKOfS B9QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779299175; x=1779903975; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Gw/ipQVPksgWoEAycGwn3lKHlvRLcLdcdo1cJCGa+ug=; b=j/8+ZifmhEdrRN1MxLEbmv58vB0P3MsZWiGWbOImkAZzsO4GnMYSjJJPFekpWU3Lz2 FXIClHpyfGuGQzP/8RRAjGUqv/j9V2augrvrbcmBoM3zyzrzyKUDeX8a+O/LAReSwnxf sKfVPurfOoEUGITkpy6mOIF1EpxeDxojmLUwLvOTMwW4comgu0o4TXcg7vkfD7yJkszO QipPzdWLNHRIZNv7y7BauI9eG1eSF2xEkxGGrOdS8p2kyjLetvR6ATyjOEXRwFrsCrbH /H9sn109EiwzGNY36lPlYqqJNbdEJSg/tD9FgehcWDWkClHV1zoZr/XtkFr0fLPz85hO G+vw== X-Forwarded-Encrypted: i=1; AFNElJ/lCZHFVEdka6bmQ8abPr7BUuWPmLMz0D4q5YVIfrrtXQoJTm3xB6mt1ib9iHRVlZK2+HJWoHOKXRLK@lists.postgresql.org X-Gm-Message-State: AOJu0Yx7PUyP9UWZYy8uUd/euSFLg8FPGGOsS9DaU6lSAhWQILj8L8l9 XOsbkohFkX+dol1siZrF6rDh3QS5347fbJtfXYyoWJeaqcSZ5iQCfZpeo/CWGYKvDl3YPLFf1uf tsjj34/1Xq0dfX6/dlVB3Ec2QJyFabZg= X-Gm-Gg: Acq92OHiXs1JCTc+nXk68heo588uD/BrO4RpK8QFYPepbvticWQfw2xtldyt+NH8MY7 nPnK0ZJSFk9XShX3qIUCba0QjgxRjXOA7u4vZFB6omM+QXpQcHQaia80X6uDxPS3DbKcTPgsdZg pXAYbRL16qRcferyciaBTthYjdpSnFHttGSiaKujDfoo3vAEVMlMbVt1wMV/4P3lkMfrdgOAmOj J/62SsL4x8qZyyk8TvVNlHPvLnHHZdiZYIeitqRhUcpHeAmZ+zGR1XKvdjAWE/QGLm21MFkK5fL fKQCcRpSgbuvVTXRKNb7yZGJv4OOaV97VWNqgchqQwckZtNWt0T+8XVgON4onEQ79ZI2c5ADPKY zZKCy X-Received: by 2002:a05:7301:688:b0:2e2:5bc5:f8eb with SMTP id 5a478bee46e88-303982c04demr11048882eec.9.1779299175411; Wed, 20 May 2026 10:46:15 -0700 (PDT) MIME-Version: 1.0 References: <19484-a3cb82c8cde3c8fa@postgresql.org> In-Reply-To: From: Etsuro Fujita Date: Wed, 20 May 2026 10:46:03 -0700 X-Gm-Features: AVHnY4KyxGAzcri7Fz0vectI0mC5fWpQ5D4ijRXd4SKgCreR_DB4Qj8G0VHQ0Jk Message-ID: Subject: Re: BUG #19484: Segmentation fault triggered by FDW To: Ayush Tiwari Cc: 798604270@qq.com, pgsql-bugs@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Wed, May 20, 2026 at 5:37=E2=80=AFAM Ayush Tiwari wrote: > On Wed, 20 May 2026 at 03:59, PG Bug reporting form wrote: >> I found the following test case triggers a segmentation fault: [snip] > Thanks for the very precise repro, that made this easy to track down. > > I reproduced the crash on master. The plan EXPLAIN under > force_generic_plan shows runtime pruning is in effect: > > Update on pt > Foreign Update on pt_p2 pt_2 > -> Append > Subplans Removed: 1 > -> Foreign Update on pt_p2 pt_2 > > The SEGV happens inside postgresBeginForeignModify() because > ExecInitModifyTable() builds re-indexed "kept" copies of several > parallel per-result-relation lists after dropping pruned relations - > withCheckOptionLists, returningLists, updateColnosLists, > mergeActionLists and mergeJoinConditions, however two members were > missed: > > - node->fdwPrivLists, read with list_nth(node->fdwPrivLists, i) when > BeginForeignModify() is called, and > - node->fdwDirectModifyPlans, checked with bms_is_member(i, ...) when > setting ri_usesFdwDirectModify. > > Both were still indexed against the original (pre-pruning) positions > while the surrounding loop's "i" is now the kept position. When the > foreign partition's kept-index no longer matched its original index, > BeginForeignModify() got the wrong fdw_private and crashed. > > Attached patch builds re-indexed kept copies for these two arrays in > the same loop as the other parallel lists, and uses them at the two > call sites. Thanks Chi for the report, and Ayush for the analysis and patch! Will revi= ew. Best regards, Etsuro Fujita