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 1wbbk0-002hbY-1E for pgsql-bugs@arkaria.postgresql.org; Mon, 22 Jun 2026 10:18:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wbbjz-0060xE-0E for pgsql-bugs@arkaria.postgresql.org; Mon, 22 Jun 2026 10:18:55 +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 1wbbjy-0060x6-2Q for pgsql-bugs@lists.postgresql.org; Mon, 22 Jun 2026 10:18:54 +0000 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wbbjv-00000001jry-3yds for pgsql-bugs@lists.postgresql.org; Mon, 22 Jun 2026 10:18:54 +0000 Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-915c48e6ae2so330967785a.2 for ; Mon, 22 Jun 2026 03:18:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782123530; x=1782728330; darn=lists.postgresql.org; h=in-reply-to:references:content-transfer-encoding:mime-version:to :from:subject:cc:message-id:date:from:to:cc:subject:date:message-id :reply-to; bh=PqeMekjAI2F/nq5V0dgaUenAPWJcEKYsMYIyDGbmfN4=; b=TycAFnU6qrF4+IFfVSadjK+t7xdBKHGiAT2dmfiUG6MbVsPn3s1JiwI1imiSG66q/d LhlGlzIac58vb/XN9RHWfU/7YQybQoFgxblJq95ifGPxqxJRtmJSM89WDW42+WMj1+fm KScKLZvqze+4Q2SFIu9kToWYOYWlUkMMgqM4FPNO3dD7O25SIOngXBTGV7SQ2cr8auEn 6kBGxHWGoy3b3QgqwFbRb3Fq195OYh4KMEQeQDyeu/CettU4mDXd1//tOJiXpph8e6F/ iGfZk6sZTSlledYcG4mEZTTRwUGpuuL+fhU4j9cj0BPGMJ6A9QyM+qQCq9orOcKvVzYP xPPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782123530; x=1782728330; h=in-reply-to:references:content-transfer-encoding:mime-version:to :from:subject:cc:message-id:date:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=PqeMekjAI2F/nq5V0dgaUenAPWJcEKYsMYIyDGbmfN4=; b=gzCBVfMo7kXq1LL0OsS1xj1rU641TdZ83vVhM2/gJfUW7nVsWMTMTdNgilChD0SqKn Mb/MH0/xyc/Ga0wJCvEb84GOmqZQ4qSwAxr33i4wAwWJLpi50egt6uTOltJKawdrt3A0 zYeDjWyLhNcj1xZ0IB2Yvb5TwPN9eg4vFtES+qjE0To9VP/PTdMzCXi5mc8m9xxDJsn+ UKNiJ6lDywsB54WufSD6LuniwrvwQdSBjobF39EqfI0E3Nsr6tBw2kH3lumid0ROw9x3 bow3iN6ttM2/Y3PXefVzmpVgeTrJLzQMu5Pd5+VyJ8CIeyEfGBUkAOtEOLItLoFFFia2 FPfw== X-Forwarded-Encrypted: i=1; AFNElJ9K5jYrV0yD+6MiO9GpPu8Mbn73BcSYyACqpsFzbcE4hA/K/hZ779vDVrb2xMYp6zEwhRdcdZiiTROK@lists.postgresql.org X-Gm-Message-State: AOJu0YxcxJOF87RLCgcyJlh/eBHQDBdHLRm184cpAHvzPX4rJms1Q1fj gcwypgP+sb6a7JAh5XPM0yzZAcKcDLOxgvRhvtcQFqepHIMeSPsG1L+NylTS5Q== X-Gm-Gg: AfdE7cnzLDgCGwWa4Ebsaj4rZwcv4j2h2g1+hzXvE+jxMp8AeKuFRqSy4iMojq5rbUe xC/tvuHjDQKMCsmrCTvoURraAePFVh4+oQgVyBI2of8cengQYrVb8AarzkbMVpLpF9brl8k/7uN qHXHkIcLz/hkc6EAH9kNKoLWMR4LGxMclqPqMzXZnloaBSx6i5QNe5t5ZMYxf/0piFOC3ghELoX BeW5j59nQEja0AeI39dSOB/xgn7VphPEbZsBuu6qW+jCdv+7MWjHfJ3aYR1eqlVRkwySJOOtszG zzv/6vSJwUsBQKvIJRTpHk4O+VRC9EjYPM/JhmvnKeWzzqW3sW0fSrNnn4QFUe7BUFKZV8Wvanr 9cGlYmZVSjmRzxJ0BQLqUlvyQNgydU+c1CaL3rJ1oyGn4zx9I6ftvmuCLM1P0mJYtpoeSS28/Ep ZkYSzEklOKDnfAD7WEUVvnIGQs2sbc6OzEhYE= X-Received: by 2002:a05:620a:29c5:b0:925:4655:aa0f with SMTP id af79cd13be357-9254655af05mr124661185a.35.1782123529828; Mon, 22 Jun 2026 03:18:49 -0700 (PDT) Received: from localhost ([2804:14d:328a:a59c:9d99:632f:faa9:5305]) by smtp.gmail.com with ESMTPSA id af79cd13be357-921daa7db7csm869750185a.23.2026.06.22.03.18.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Jun 2026 03:18:49 -0700 (PDT) Content-Type: text/plain; charset=UTF-8 Date: Mon, 22 Jun 2026 07:18:46 -0300 Message-Id: Cc: , Subject: Re: BUG #19480: PL/Python SRF crashes (SIGSEGV) when function is replaced mid-iteration: use-after-free in PLy_funct From: "Matheus Alcantara" To: "Tom Lane" Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: aerc 0.21.0 References: <19480-f1f9fdce30462fc4@postgresql.org> <982975.1779981146@sss.pgh.pa.us> <2868592.1780356411@sss.pgh.pa.us> <1149447.1781733399@sss.pgh.pa.us> <381335.1782070804@sss.pgh.pa.us> In-Reply-To: <381335.1782070804@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun Jun 21, 2026 at 4:40 PM -03, Tom Lane wrote: > "Matheus Alcantara" writes: >> Thanks for the review! I've tried to address all your points in the >> attached v2. > > Pushed after a round of review. I made some mostly-cosmetic changes, > such as rewriting comments (consolidating some stuff I thought was > duplicative). The main thing I fixed that was an actual bug was > you were careless about lifespan of variables around PG_TRY blocks. > The rule of thumb is that if a variable is modified inside PG_TRY > and then used after that block (including in the PG_CATCH) then it > has to be marked volatile. Where possible, I avoid using the > volatile marking by assigning the variable's value before PG_TRY. > Noted, thanks for the call. >> I've also added a regression test, not sure if there is a better way to >> exercise this fix but this test crash without this patch applied. > > Kind of a hokey test, since it doesn't model the likely actual case > where the CREATE happens in another session, but this is as close as > we'll get without a much more complex test setup. I kept it, and > also added another test that exercises the early-termination path, > since code coverage showed me that ShutdownPLyFunction() wasn't being > reached. > Thank you for reviewing and committing the patch! -- Matheus Alcantara EDB: https://www.enterprisedb.com