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 ?


#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
        fullname = 0x84d248 "/usr/local/pgsql/lib/plperl.so"
        lib_handle = <value temporarily unavailable, due to optimizations>
        retval = (PGFunction) 0x12
        __func__ = "load_external_function"
#19 0x000703b7 in fmgr_c_validator (fcinfo=0x852400) at pg_proc.c:509
        funcoid = <value temporarily unavailable, due to optimizations>
        libraryhandle = <value temporarily unavailable, due to optimizations>
        tuple = (HeapTuple) 0x84d248
        isnull = 0 '\0'
        tmp = <value temporarily unavailable, due to optimizations>
        prosrc = 0x84d090 "plperl_call_handler"
        __func__ = "fmgr_c_validator"
#20 0x002692f9 in OidFunctionCall1 (functionId=8725504, arg1=8725504) at 
fmgr.c:1533
        flinfo = {
  fn_addr = 0x702a0 <fmgr_c_validator>, 
  fn_oid = 2247, 
  fn_nargs = 1, 
  fn_strict = 1 '\001', 
  fn_retset = 0 '\0', 
  fn_extra = 0x0, 
  fn_mcxt = 0x80f7d8, 
  fn_expr = 0x0
}
        fcinfo = {
  flinfo = 0xbfffde38, 
  context = 0x0, 
  resultinfo = 0x0, 
  isnull = 0 '\0', 
  nargs = 1, 
  arg = {40960, 3221216440, 1693582, 54, 0, 0, 0, 8708240, 8442524, 8444804, 
2545207, 8444812, 8444812, 20, 0, 8661112, 8442524, 8444804, 2545207, 8444812, 
3221216652, 20, 1, 52335640, 8442508, 8444984, 2545207, 8444992, 8444992, 20, 
1679523, 3221216464, 8442508, 8444984, 2545207, 8444992, 3221216716, 20, 
543661892, 1273804351, 8440928, 20, 1683774, 2482979872, 8444812, 3221216552, 
2621638, 8440856, 8440928, 20, 2621638, 2482979872, 8661888, 8422224, 
3123422035, 1281850385, 2487039675, 8, 2436859, 7487432, 4952088, 3221216600, 
2624137, 8422224, 7487432, 2558151799, 2, 0, 7487432, 3221216648, 2436930, 
7487432, 48, 3221216648, 1683832, 8440856, 8444992, 7487224, 2437115, 7487432, 
4952088, 3221216712, 2437344, 48, 0, 0, 0, 0, 0, 3358052, 0, 51977820, 8661272, 
2437115, 2445025, 52335640, 3468288, 16768504, 16777472, 31}, 
  argnull = 
"\000ˆÅ\030ð\005\032\000\033€\031\000\000\000\000\000\020Þÿ¿8Þÿ¿|€\031\000\005\000\000\000\001\000\000\000\020Þÿ¿ƒL%\000t©ƒ\000\003\000\000\000\000\000\000\000Ók%\000d©ƒ\000ç\004\000\000ÐN%\000
 ¨ƒ\000\000\000\000\000$¨ƒ\000\033€\031\000ùP%\000\000\000\000\000x„„"
}
        result = <value temporarily unavailable, due to optimizations>
        __func__ = "OidFunctionCall1"
#21 0x0006fa59 in ProcedureCreate (procedureName=0x847740 
"plperl_call_handler", procNamespace=11, replace=0 '\0', returnsSet=0 '\0', 
returnType=2280, languageObjectId=13, languageValidator=2247, prosrc=0x852400 
"\004ȃ", probin=0x852400 "\004ȃ", isAgg=0 '\0', security_definer=0 '\0', 
isStrict=0 '\0', volatility=118 'v', parameterTypes=0x847e40, 
allParameterTypes=0, parameterModes=0, parameterNames=0, proconfig=0, 
procost=1.22270354e-38, prorows=1.22270354e-38) at pg_proc.c:413
        retval = 40960
        parameterCount = 0
        allParamCount = 0
        allParams = (Oid *) 0x847e58
        genericInParam = <value temporarily unavailable, due to optimizations>
        genericOutParam = <value temporarily unavailable, due to optimizations>
        internalInParam = 0 '\0'
        internalOutParam = 0 '\0'
        rel = (Relation) 0x4b8ed0
        tup = (HeapTuple) 0xa000
        oldtup = (HeapTuple) 0x0
        nulls = ' ' <repeats 14 times>, "nnn  nn"
        values = {3221217068, 11, 10, 13, 8704032, 8704048, 0, 0, 0, 0, 118, 0, 
2280, 8683072, 0, 0, 0, 8704064, 8704104, 0, 0}
        replaces = 'r' <repeats 21 times>
        relid = <value temporarily unavailable, due to optimizations>
        procname = {
  data = "plperl_call_handler", '\0' <repeats 44 times>, 
  alignmentDummy = 1701866608
}
        tupDesc = (TupleDesc) 0x4d20a0
        is_update = 0 '\0'
        myself = {
  classId = 1255, 
  objectId = 40960, 
  objectSubId = 0
}
        referenced = {
  classId = 1247, 
  objectId = 2280, 
  objectSubId = 0
}
        i = 0
        __func__ = "ProcedureCreate"
#22 0x000cae74 in CreateProceduralLanguage (stmt=0x82e660) at proclang.c:130
        funcname = (List *) 0x847650
        languageName = 0x847640 "plperl"
        pltemplate = (PLTemplate *) 0x847990
        handlerOid = 0
        valOid = <value temporarily unavailable, due to optimizations>
        funcrettype = <value temporarily unavailable, due to optimizations>
        funcargtypes = <value temporarily unavailable, due to optimizations>
        __func__ = "CreateProceduralLanguage"
#23 0x001acca8 in MemoryContextSwitchTo [inlined] () at palloc.h:1173
        __func__ = "PortalRunUtility"
#24 0x001acca8 in PortalRunUtility (portal=0x848618, utilityStmt=0x82e660, 
isTopLevel=1 '\001', dest=0x852400, completionTag=0x852400 "\004ȃ") at 
pquery.c:1181
        context = (MemoryContext) Cannot access memory at address 0x0



Thanks,
--
Alexey Klyukin       http://www.CommandPrompt.com
The PostgreSQL Company - Command Prompt, Inc.

-- 
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to