I'm trying to initialize a Perl interpreter in my C program and
have it compile a perl script that spawns one Perl thread, which
will communicate via the main Perl thread with the C program.
Can anybody guess what I might be doing wrong and it will always
core dump at Perl_newSV or Perl_newSVpvn (it is not deterministic and
depends on the thread timing)? The thread stuff I'm doing in Perl
might not be related with this problem, but I just mentioned it
in case it is...
Following are a few details of how I compiled my C program and the
problem I'm seeing with gdb.
Any help much appreciated!
Yannis
------------------------------------------------------------------
This is how test.c is compiled,
gcc -g -D_REENTRANT -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
-I/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/CORE
-I/adc_local_apps/vcs/vcs6.0/sun_sparc_solaris_5.5.1/lib -DSunOS -c test.c
and how it is linked into an executable
gcc -o a.out test.o [other .o's]
-lnsl -lsocket -ldl /usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/B/B.a
/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/ByteLoader/ByteLoader.a
/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/Data/Dumper/Dumper.a
/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/Devel/DProf/DProf.a
/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/Devel/Peek/Peek.a
/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/Fcntl/Fcntl.a
/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/File/Glob/Glob.a
/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/IO/IO.a
/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/IPC/SysV/SysV.a
/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/NDBM_File/NDBM_File.a
/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/ODBM_File/ODBM_File.a
/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/Opcode/Opcode.a
/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/POSIX/POSIX.a
/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/SDBM_File/SDBM_File.a
/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/Socket/Socket.a
/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/Sys/Hostname/Hostname.a
/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/Sys/Syslog/Syslog.a
/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/Thread/Thread.a
/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/attrs/attrs.a
/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/re/re.a
/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/CORE/libperl.a -lsocket -lnsl -ldl -lm
-lposix4 -lpthread -lc -lcrypt -lsec
/adc_local_apps/vcs/vcs6.0/sun_sparc_solaris_5.5.1/lib/libvcs.a
/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/DynaLoader/DynaLoader.a -lm -lc
-ldl
This is the stack from gdb:
#0 0x12b45dc in Perl_newSVpvn ()
#1 0x12d3614 in S_doeval ()
#2 0x12d5640 in Perl_pp_entereval ()
#3 0x125210c in S_call_body ()
#4 0x12522ec in Perl_eval_sv ()
#5 0x12524f0 in Perl_eval_pv ()
#6 0x69db7c in getLine (rd=1,
line=0xffb43a98 "0 print Notice: Will use static file") at test.c:741
#7 0x6a4840 in scan_up_pipe (save=1, args=0xffbee988, want_out=0xffbee984)
at test.c:2725
#8 0x6a4cb4 in arena_start () at test.c:2807
#9 0x14694c8 in Spli ()
#10 0x6bb764 in Rganges2_tb_2iJaFb_1_216 ()
#11 0x133ed8c in CauseAllTS32 ()
#12 0x133c0a8 in VCS_MAIN ()
#13 0x6a7c08 in main ()
and here is how I initialize the perl interpreter.
void perlInit() {
char *args[] = { "perl", "-e", "exit;" };
printf("C: Initializing Perl interpreter\n");
my_perl = perl_alloc();
perl_construct(my_perl);
perl_parse (my_perl, xs_init, 3, args, (char **)NULL);
{ dTHX; perl_eval_pv ("require 'test.pl';", TRUE); }
}