http://www.perlmonks.org?node_id=967175


in reply to Re: SvPV Segmentation Fault
in thread SvPV Segmentation Fault

Ok, that worked:

./svpv.pl Starting Build Preprocess Stage + + + Finished Build Preprocess Stage + + + + + + Starting Build Parse Stage Finished Build Parse Stage Starting Build Glue 1 Stage Finished Build Glue 1 Stage Starting Build Glue 2 Stage Finished Build Glue 2 Stage Starting Build Glue 3 Stage Finished Build Glue 3 Stage Starting Build Compile Stage Starting "perl Makefile.PL" Stage Writing Makefile for _967160 Writing MYMETA.yml Finished "perl Makefile.PL" Stage Starting "make" Stage /usr/bin/perl /usr/lib/perl5/5.14.2/ExtUtils/xsubpp -typemap /usr/lib +/perl5/5.14.2/ExtUtils/typemap _967160.xs > _967160.xsc && mv _9671 +60.xsc _967160.c cc -c -I/home/kadler -D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTEN +V -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D +_FILE_OFFSET_BITS=64 -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 + -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -W +all -pipe -DVERSION=\"0.00\" -DXS_VERSION=\"0.00\" -fPIC "-I/usr/li +b/perl5/5.14.2/x86_64-linux-thread-multi/CORE" _967160.c Running Mkbootstrap for _967160 () chmod 644 _967160.bs rm -f blib/arch/auto/_967160/_967160.so cc -shared -L/usr/local/lib64 -fstack-protector _967160.o -o blib/ar +ch/auto/_967160/_967160.so \ \ chmod 755 blib/arch/auto/_967160/_967160.so cp _967160.bs blib/arch/auto/_967160/_967160.bs chmod 644 blib/arch/auto/_967160/_967160.bs Finished "make" Stage Starting "make install" Stage Files found in blib/arch: installing files in blib/lib into architectu +re dependent library tree Installing /home/kadler/_Inline/lib/auto/_967160/_967160.bs Installing /home/kadler/_Inline/lib/auto/_967160/_967160.so Finished "make install" Stage Starting Cleaning Up Stage Finished Cleaning Up Stage Finished Build Compile Stage fred 1

But, I wasn't actually using Inline::C. Just using that as an example of using SvPV and SvPV_nolen to build my XS module. There must be something wrong with building my XS module, then.

I've been using perlxstut as a basis, specifically examples #4 and #5.

Here's mylib.c:
#include <stdlib.h> #include "mylib.h" PerlInterpreter *my_perl; void foo(SV * sv) { if(sv) { printf("%s\n", SvPV_nolen(sv)); } } void bar(SV * sv) { printf ("%i\n", SvPOK(sv)); }
Here's mylib.h:
#include "EXTERN.h" #include "perl.h" #define TESTVAL 4 void foo(SV * sv); void bar(SV * sv);
Here's Mytest2.xs:
#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" #include "mylib/mylib.h" #include "const-c.inc" MODULE = Mytest2 PACKAGE = Mytest2 INCLUDE: const-xs.inc void foo(SV * sv) void bar(SV * sv)
Everything else should be exactly as in perlxstut.