Re: Bug plperl.c

From: Mark Murawski <markm-lists(at)intellasoft(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Bug plperl.c
Date: 2022-02-22 20:27:09
Message-ID: bcfaa4e4-6699-8c8b-0201-37889ff3b1e8@intellasoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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(\(at)_));
  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(at)intellasoft(dot)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
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David Rowley 2022-02-22 23:33:19 Re: Bug in execution of EXISTS and IN clauses for large tables
Previous Message Mark Murawski 2022-02-22 20:06:19 Re: Bug plperl.c