Trying to use the perl data structure (partly as a way to support an associative array in C), but the following program continues to crash. It compiles fine, but there will be a crash on the line using newSVpv (). I do not know why.
#include <EXTERN.h> /* from the Perl distribution */
#include <perl.h> /* from the Perl distribution */
static PerlInterpreter *my_perl;
int main(int argc, char **argv, char **env) {
char *proto = "http";
SV* ret = newSVpv("http", 4);
sv_catpvn(ret, "://", 3);
STRLEN len = 1;
char *result = SvPV(ret, len);
printf("result: %p %d\n", result, len);
return 0;
}
The string to compile is -
gcc -g -o interp te1.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
Perl I have 5.14.2 running on Ubuntu 12.04.4 LTS.
Thanks for any tips!
UPDATE: added gdb trace. Thanks for the question. gdb trace:
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7b235a6 in Perl_newSVpv () from /usr/lib/libperl.so.5.14
(gdb) bt
env=0x7fffffffe1f8) at te1.c:7
(gdb)
source
share