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 1wQWvm-001cYF-0E for pgsql-bugs@arkaria.postgresql.org; Fri, 22 May 2026 20:57:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wQWuj-00EjVP-1W for pgsql-bugs@arkaria.postgresql.org; Fri, 22 May 2026 20:56:14 +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 1wQWuj-00EjVH-0f for pgsql-bugs@lists.postgresql.org; Fri, 22 May 2026 20:56:14 +0000 Received: from mail-vk1-xa30.google.com ([2607:f8b0:4864:20::a30]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wQWuh-00000000wkl-2ncV for pgsql-bugs@lists.postgresql.org; Fri, 22 May 2026 20:56:13 +0000 Received: by mail-vk1-xa30.google.com with SMTP id 71dfb90a1353d-56f72d27e7eso8971815e0c.0 for ; Fri, 22 May 2026 13:56:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779483370; x=1780088170; darn=lists.postgresql.org; h=in-reply-to:references:to:from:subject:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=wRuCUsQcAAlNpScdIhQ6wNudKQ+/2oTuyF9PcpCSwgI=; b=Zvq+VFHo68/4eOIXfZWNDAiJqn/2yzP+gOlKHBGST+dZhZYfCEQtnKB2e7yjgFeOem G4iuSU1tW7uKxXqhlfpqkm4DXfZPE3Mr3iRz5BONLAY7uaRlhs7PUCSklbLZjMi859c/ TnyN5OzYLyByBQ37tgmAUL0pSoQ76BWZOIOjyDSyVBnHAy5J2TJwgtpej1Z1nJhKyx2t H6DjvnAQlbr/D8+IPsqq74g2/M1hpBWcaD5L2W+XRe6dbm/9hSLb4fDJii6Fmv2qfEQP yOXiZQ4i7TUtujHSN5rtfd8mneV9bozEQAqSM+V04UpuJZN1i9OB8qqUuYLWb9Z0gt91 owBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779483370; x=1780088170; h=in-reply-to:references:to:from:subject:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=wRuCUsQcAAlNpScdIhQ6wNudKQ+/2oTuyF9PcpCSwgI=; b=WRsEaPVkCf/dSFNfwzQ0JIf6OmKt6XqECn6zOIB4Wvd9NLuT/8+W8ro6NILpZOQ4dZ uwQFTgofVB9s1FyNKzxNTbjEDI+tZhauk4DtZheLDmGvsUrMFB70vKrAhqrdWyzlBJIj HcR0X8N7Wp/Lbx7a0ztMRI3BRocngkCzQL3b12Kx+9OsP0K77MFMmTBPRXmB60B0DGYv xqHewadLi/tyu/q/+Jl0qbKXTg1KpVupo4EiNeIJdxYdEU1moz4E3V3cJgu3ZkX6as+Y sWEIRGO7UvjgjNuCNMn/5AgWIiHfl/bYM9JfWsNKYbr0lXi2ODS+dtn6gykDwG4TTmGc pVQg== X-Forwarded-Encrypted: i=1; AFNElJ/ajAlT8co9D+ux7HG/f3aTnUaNqwXP6KgfD2HHm6tpGNwu/uM0NTPqCKZP7BLusc48UL6+JF2nJKtG@lists.postgresql.org X-Gm-Message-State: AOJu0YzM8TMxNf9KMEKCKntL1CyMf4raYxmHCnrBArHmdduHuryxcxFA 2S3BmAAgrgHN8+h0e9BF/s58WHry0xjmiApBPmI9/9hZIcQwnNaj+KE0 X-Gm-Gg: Acq92OEi2vzmMHxNIpGkH2v5pa6kT2IX6VaWF4sI5TDN8eGY8/XSlMM6kfwDpaGuNbV jEFRsfnqoyGQNz9bvuXDha/0O/RTvTRZw8ZQCgGQCQjH8IUXZlXHs+GKO9nKIBihFJjTGqJPU+Q zaCKjSoCOB53jGHobQkRyWvbt11YmMZYb1rml7eEgJAEZcxw1W/ui6I8QHwAZ90Ix6FWyr87gFL ZUIikLvCXAi/nDZh3AiyTLvTTbo6njx2xiDCCJRNMsUQ2vF8hIOYmGaXDFJ/ZM1UCVVWK5SneP6 LepVPyQX6DZWKEIDlpe9NF0dyiNt5t8j8qsJeMbGB+VcROo7s1YeQrL3JavKTE8E2A5yjjw19Xf XmFl70Il1nbH3X7t0p9zIN9EM9Lo6S3JMYoGJWqYFCEGkHupHPGSA1I5+TlyvVs7zLii9lQlceS JcdTlcj6DOTQeA2lJiuAcDblvBa2L4sr5MfZrUkH0tK8Io9w== X-Received: by 2002:a05:6122:490a:b0:575:fa0b:bc23 with SMTP id 71dfb90a1353d-586890d0d6emr2208921e0c.2.1779483369917; Fri, 22 May 2026 13:56:09 -0700 (PDT) Received: from localhost ([2804:14d:328a:a59c:a09d:ab88:301a:71a4]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-586f23eea07sm3768577e0c.4.2026.05.22.13.56.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 22 May 2026 13:56:09 -0700 (PDT) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 22 May 2026 17:56:05 -0300 Message-Id: Subject: Re: BUG #19484: Segmentation fault triggered by FDW From: "Matheus Alcantara" To: "Ayush Tiwari" , <798604270@qq.com>, , "Etsuro Fujita" X-Mailer: aerc 0.21.0 References: <19484-a3cb82c8cde3c8fa@postgresql.org> In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed May 20, 2026 at 9:37 AM -03, Ayush Tiwari wrote: > 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. > Hi, thanks for the patch. This issue started on version 18 by commit cbc127917e0. The patch fixes the issue and it make sense to me. One a minor comment is that I think pg_indent is needed on nodeModifyTable.c -- Matheus Alcantara EDB: https://www.enterprisedb.com