Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TBV1d-0000wA-K5 for pgsql-bugs@postgresql.org; Tue, 11 Sep 2012 18:17:29 +0000 Received: from globepointer.com ([213.157.92.217]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TBV1b-0004ep-Ne for pgsql-bugs@postgresql.org; Tue, 11 Sep 2012 18:17:29 +0000 Received: from [95.209.87.171] (95.209.87.171.bredband.tre.se [95.209.87.171]) (Authenticated sender: pgmail) by globepointer.com (Postfix) with ESMTP id 2FD31BB25; Tue, 11 Sep 2012 21:17:25 +0300 (EEST) Message-ID: <504F8034.20802@joh.to> Date: Tue, 11 Sep 2012 20:17:24 +0200 From: Marko Tiikkaja User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120824 Thunderbird/15.0 MIME-Version: 1.0 To: Tom Lane CC: pgsql-bugs@postgresql.org Subject: Re: BUG #7516: PL/Perl crash References: <1194.1346688396@sss.pgh.pa.us> <5047BA9C.2040405@joh.to> <16153.1347226320@sss.pgh.pa.us> <17785.1347230278@sss.pgh.pa.us> In-Reply-To: <17785.1347230278@sss.pgh.pa.us> Content-Type: multipart/mixed; boundary="------------060609080405080503050601" X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201209/92 X-Sequence-Number: 34087 This is a multi-part message in MIME format. --------------060609080405080503050601 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 10/09/2012 00:37, Tom Lane wrote: > The attached patch fixes the problem I'm seeing. I am not sure whether > it fixes what you saw; the crash you showed is in the right place, but > unless there was a recursive call to a pl/perl function, I don't see > how the existing code could have freed the prodesc too soon. Joel Jacobson managed to narrow it down to this test case, which crashes consistently on Ubuntu 12.04 both with and without your patch. I, however, wasn't able to reproduce the problem on my OS X Mountain Lion. I'll try to get some more information about it tomorrow, but in the mean time if you can reproduce the problem or think of something, I'll post the test case. Regards, Marko Tiikkaja --------------060609080405080503050601 Content-Type: text/plain; charset=windows-1252; name="perlbug.sql" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="perlbug.sql" DROP DATABASE plperlbug; CREATE DATABASE plperlbug; \c plperlbug CREATE LANGUAGE plperlu; CREATE TABLE t1 ( fooid serial not null, foo character(3) NOT NULL, PRIMARY KEY (fooid), UNIQUE (foo) ); CREATE TABLE t2 ( foobarid serial not null, foobar1 character(3) NOT NULL, foobar2 character(3) NOT NULL, PRIMARY KEY (foobarid), UNIQUE (foobar1,foobar2) ); CREATE TABLE t3 ( foobarid integer NOT NULL, foobar4 timestamp with time zone NOT NULL, foo1 numeric NOT NULL, foo2 numeric NOT NULL, foo3 interval NOT NULL, PRIMARY KEY (foobarid), CONSTRAINT t3_foo1_check CHECK ((foo1 > (0)::numeric)) ); CREATE OR REPLACE FUNCTION func0001(_foobar1 character, _foobar2 character) RETURNS integer AS $BODY$ SELECT foobarid FROM t2 WHERE foobar1 = $1 AND foobar2 = $2 $BODY$ LANGUAGE sql; CREATE OR REPLACE FUNCTION func0005() RETURNS record LANGUAGE plperlu AS $BODY$ use strict; use warnings; die "die for fun"; $BODY$; CREATE OR REPLACE FUNCTION func0002( OUT foobar4_ timestamp with time zone, OUT foo1_ numeric, OUT foo2_ numeric, _foobar1 character, _foobar2 character, _foobar3 timestamp with time zone ) RETURNS record AS $BODY$ DECLARE _foobarid integer; _foo3 interval; BEGIN _foobarid := func0001(_foobar1, _foobar2); BEGIN RAISE DEBUG '% % %', 'a', 'b', 'c'; PERFORM func0005(); EXCEPTION WHEN OTHERS THEN RAISE DEBUG '%', 'foo'; SELECT foobar4, foo1, foo2, foo3 INTO foobar4_, foo1_, foo2_, _foo3 FROM t3 WHERE foobarid = 12345; END; RETURN; END; $BODY$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION func0003() RETURNS boolean AS $FUNC$ use strict; use warnings; my $prepared = spi_prepare('SELECT * FROM func0002($1,$2,NULL)', 'VARCHAR','VARCHAR'); my $a = spi_exec_prepared($prepared,'AAA','BBB')->{rows}->[0]->{fx}; my $b = spi_exec_prepared($prepared,'AAA','BBB')->{rows}->[0]->{fx}; return 1; $FUNC$ LANGUAGE plperlu; SELECT func0003(); --------------060609080405080503050601--