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 1nMbkm-0007gn-HG for pgsql-bugs@arkaria.postgresql.org; Tue, 22 Feb 2022 20:27:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nMbkk-0007eT-8z for pgsql-bugs@arkaria.postgresql.org; Tue, 22 Feb 2022 20:27:18 +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 1nMbkj-0007eK-Q6 for pgsql-bugs@lists.postgresql.org; Tue, 22 Feb 2022 20:27:17 +0000 Received: from mail2.intellasoft.net ([64.120.46.178] helo=mail.bluekaba.com) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nMbkd-0001Zm-6s for pgsql-bugs@lists.postgresql.org; Tue, 22 Feb 2022 20:27:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=intellasoft.net; s=msb; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:References:Cc:To:From:Subject:MIME-Version:Date:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=tTxcf+8RhRnNJBziTLCCfgRytT+FP7HhsYgRlFTjOBU=; b=pob0tnUleqJ+qAi8QWwtE+Jtls c3/Wdbp/DVgaMHl0FU+cVtSYAfQd9qYmCfyLG97Fj1WuMErLVpdCZMCiEMvvHPMV12iRkfv9xsvUR FNPtv7io6zTQ+WUNbujiBWAqALaYX7NucubNibdeCLaHthrPmV4FHbcM8UdX73OO3s8IPGWpj4F2p CzcD2E9bN08rmd6kvFkniabGpP2QCG66rqVgyI+/hiGiKX/cTns2An2OkfqGv8gI76JEhGP6qX9KW KtnWZzaM6svVKjRXDx1B6ODyfw+RkJ9JrUOsQlUDlZZMG8+NhngmMZahnQZQyn/dC3GhHFSDFwXZS dLc4M8eQ==; Message-ID: Date: Tue, 22 Feb 2022 15:27:09 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: Bug plperl.c Content-Language: en-US From: Mark Murawski To: Tom Lane Cc: pgsql-bugs@lists.postgresql.org References: <9acdf918-7fff-4f40-f750-2ffa84f083d2@intellasoft.net> <821293.1645559302@sss.pgh.pa.us> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Tom Here you go: CREATE OR REPLACE FUNCTION public.foo()  RETURNS text  LANGUAGE plperlu AS $function$ use warnings; use strict; use lib '/tmp'; use foo; my @a; my @a; $function$ --- /tmp/foo.pm --- package foo; use Data::Dumper; $SIG{'__WARN__'} = sub {    my $pid = main::spi_exec_query('SELECT pg_backend_pid()')->{rows};   main::elog(main::NOTICE, 'Warning:' . Dumper(\@_));   main::elog(main::NOTICE, 'foo: ' . $pid); }; 1; On 2/22/22 15:06, Mark Murawski wrote: > Hi Tom, > > Wow that was fast! > > Upon further testing, my path isn't a full fix... there's other parts > of the flow that needs current_call_data > > > I trimmed down my example from the guts of a complex application. > Sorry I didn't re-test with the trimmed example.  But the use-case is > very much the same... it has to do with running spi_exec_query during > parse time. > > I'll work on redoing the example to reproduce the crash. > > > > On 2/22/22 14:48, Tom Lane wrote: >> Mark Murawski writes: >>> Affects Versions: 12 (and probably all others) >>> Steps to Reproduce: >>> - Run a query during plperl validation -- ie: inside a warn handler >>> 2022-02-22 12:17:04 EST -  -  -  - 12950 -  - 0 - LOG:  server process >>> (PID 19702) was terminated by signal 11: Segmentation fault >> I couldn't reproduce this, either in HEAD or 12.10.  However, maybe >> there's something faulty about your example, because in my hands it >> doesn't seem that plperl_spi_exec is reached at all. >> >> If we do need to do something here, my inclination would be to >> reject execution of any SPI operations during validation. That's >> not a case that's supposed to have any side-effects. >> >>             regards, tom lane >