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: 0x0004
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 ?
#0 0x035048f5 in Perl_sv_replace ()
No symbol table info available.
#1 0x035209c8 in Perl_leave_scope ()
No symbol table info available.
#2 0x035215fc in Perl_pop_scope ()
No symbol table info available.
#3 0x0352b0ec in Perl_die_where ()
No symbol table info available.
#4 0x034cf462 in Perl_vcroak ()
No symbol table info available.
#5 0x034cf545 in Perl_croak ()
No symbol table info available.
#6 0x034e2d27 in Perl_call_list ()
No symbol table info available.
#7 0x0349a307 in S_process_special_blocks ()
No symbol table info available.
#8 0x034a90d5 in Perl_newATTRSUB ()
No symbol table info available.
#9 0x034a9872 in Perl_utilize ()
No symbol table info available.
#10 0x03495ad0 in Perl_yyparse ()
No symbol table info available.
#11 0x03526e2b in S_doeval ()
No symbol table info available.
#12 0x035307c3 in Perl_pp_entereval ()
No symbol table info available.
#13 0x034e220c in Perl_eval_sv ()
No symbol table info available.
#14 0x034e2295 in Perl_eval_pv ()
No symbol table info available.
#15 0x004e3230 in plperl_init_interp () at plperl.c:445
res = (SV *) 0x852400
embedding = {0x4ec9a2 , 0x4ec9e0 -e, 0x4ec9e4 SPI::bootstrap();
use vars qw(%_SHARED);sub ::plperl_warn { my $msg = shift;$msg =~
s/\\(eval \\d+\\) //g; elog(NOTICE, $msg); } $SIG{__WARN__} =
\\::plperl_warn; sub ::plperl_die { my $msg = s...}
__func__ = plperl_init_interp
#16 0x004e3606 in _PG_init () at plperl.c:214
inited = 0 '\0'
hash_ctl = {
num_partitions = 0,
ssize = 0,
dsize = 0,
max_dsize = 0,
ffactor = 0,
keysize = 64,
entrysize = 68,
hash = 0,
match = 0,
keycopy = 0,
alloc = 0,
hcxt = 0x0,
hctl = 0x0
}
#17 0x00266a8e in internal_load_library (libname=0x84d248
/usr/local/pgsql/lib/plperl.so) at dfmgr.c:296
file_scanner = (DynamicFileList *) 0x852400
load_error = 0x4ec97c \024
stat_buf = {
st_dev = 234881026,
st_ino = 11868721,
st_mode = 33261,
st_nlink = 1,
st_uid = 0,
st_gid = 0,
st_rdev = 0,
st_atimespec = {
tv_sec = 1249929440,
tv_nsec = 0
},
st_mtimespec = {
tv_sec = 1249924863,
tv_nsec = 0
},
st_ctimespec = {
tv_sec = 1249924863,
tv_nsec = 0
},
st_size = 70616,
st_blocks = 144,
st_blksize = 4096,
st_flags = 0,
st_gen = 0,
st_lspare = 0,
st_qspare = {0, 0}
}
__func__ = internal_load_library
#18 0x0026757e in load_external_function (filename=0x852400 \004È,
funcname=0x84d090 plperl_call_handler, signalNotFound=1 '\001',
filehandle=0xbfffdbf8) at dfmgr.c:110