Re: PL/Perl crash when using threaded perl

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Alexey Klyukin <alexk(at)commandprompt(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: PL/Perl crash when using threaded perl
Date: 2009-08-10 19:09:41
Message-ID: 4A807075.8030007@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alexey Klyukin wrote:
> Hi,
>
> I was recently running both pl/perl and pl/perlu functions in a single
> session, coming across the error message about failure to allocate a
> second Perl interpreter on my platform. I'm running PostgreSQL 8.3.7
> built from the sources on Mac OS X 10.5 with perl installed from
> macports (macports were synced recently and up-to-date). I've noticed
> that threads are not enabled in the macports package.
>
> Then I've reinstalled Perl, enabling a build with threading support,
> since the documentation on PL/Perl hinted me on this.
> My macports package looks like this:
>
> alexk$ port echo perl5.8 and installed
> perl5.8 @5.8.9_3+shared+threads
>
> and the Perl flags are:
>
> alexk$ perl -V
> ....
> Characteristics of this binary (from libperl):
> Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT
> PERL_MALLOC_WRAP
> USE_FAST_STDIO USE_ITHREADS USE_LARGE_FILES
> USE_PERLIO USE_REENTRANT_API
> Built under darwin
> Compiled at Aug 10 2009 16:57:14
> @INC:
> /opt/local/lib/perl5/site_perl/5.8.9/darwin-thread-multi-2level
> /opt/local/lib/perl5/site_perl/5.8.9
> /opt/local/lib/perl5/site_perl
> /opt/local/lib/perl5/vendor_perl/5.8.9/darwin-thread-multi-2level
> /opt/local/lib/perl5/vendor_perl/5.8.9
> /opt/local/lib/perl5/vendor_perl
> /opt/local/lib/perl5/5.8.9/darwin-thread-multi-2level
> /opt/local/lib/perl5/5.8.9
>
> Now PL/Perl just crashes a backend even when I try to create a
> language itself.
>
> postgres=# create language plperl;
> server closed the connection unexpectedly
> This probably means the server terminated abnormally
> before or while processing the request.
> The connection to the server was lost. Attempting reset: Failed.
>
> and gdb tells me this:
>
> Attaching to program: `/usr/local/pgsql/bin/postgres', process 9067.
> Reading symbols for shared libraries ++. done
> 0x9403a749 in recvfrom$UNIX2003 ()
> (gdb) c
> Continuing.
> Reading symbols for shared libraries ... done
>
> Program received signal EXC_BAD_ACCESS, Could not access memory.
> Reason: KERN_PROTECTION_FAILURE at address: 0x00000004
> 0x035048f5 in Perl_sv_replace ()
>
> bt full from the running process is attached. Is there a problem with
> perl built via macports (I can see both USE_ITHREADS and MULTIPLICITY,
> although documentation tells about building with either of them), or
> is this a bug in PL/Perl ?

I wonder if this is another case of the lack of perl library
initialisation bug we have seen before. Can you try with this patch to
the postgres 8.3 sources?
<http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/pl/plperl/plperl.c.diff?r1=1.136;r2=1.136.2.2>

We haven't put out an 8.3 release that includes that patch yet.

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2009-08-10 19:32:47 Re: Patch for 8.5, transformationHook
Previous Message Pavel Stehule 2009-08-10 19:04:10 Re: Issues for named/mixed function notation patch