pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Murawski <markm-lists@intellasoft.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Bug plperl.c
Date: Tue, 22 Feb 2022 15:27:09 -0500
Message-ID: <bcfaa4e4-6699-8c8b-0201-37889ff3b1e8@intellasoft.net> (raw)
In-Reply-To: <d57829b8-e0b3-ee63-8966-f2267e7ffa41@intellasoft.net>
References: <9acdf918-7fff-4f40-f750-2ffa84f083d2@intellasoft.net>
	<821293.1645559302@sss.pgh.pa.us>
	<d57829b8-e0b3-ee63-8966-f2267e7ffa41@intellasoft.net>

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 <markm-lists@intellasoft.net> 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
>






view thread (8+ messages)  latest in thread

Message-ID: <bcfaa4e4-6699-8c8b-0201-37889ff3b1e8@intellasoft.net>
Permalink:  ../bcfaa4e4-6699-8c8b-0201-37889ff3b1e8@intellasoft.net/
Also on:    postgresql.org/message-id/bcfaa4e4-6699-8c8b-0201-37889ff3b1e8@intellasoft.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: markm-lists@intellasoft.net, tgl@sss.pgh.pa.us
  Subject: Re: Bug plperl.c
  In-Reply-To: <bcfaa4e4-6699-8c8b-0201-37889ff3b1e8@intellasoft.net>
  References: <9acdf918-7fff-4f40-f750-2ffa84f083d2@intellasoft.net> <821293.1645559302@sss.pgh.pa.us> <d57829b8-e0b3-ee63-8966-f2267e7ffa41@intellasoft.net> <bcfaa4e4-6699-8c8b-0201-37889ff3b1e8@intellasoft.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox