in reply to [I::C] Why does it segfault?
When loading the respective core file into gdb, it indicated that the segfault had occurred when calling SvLEN_set():
$ gdb /usr/local/bin/perl core ... Core was generated by `/usr/local/bin/perl -lw ./959669.pl 128'. Program terminated with signal 11, Segmentation fault. #0 0x00007f8382eb85c5 in new (classname=0x11b1170 "fred", bits=<optim +ized out>) at test.xs:23 23 SvLEN_set( obj, bytes ); (gdb) q
My guess would be this is because the SV created with nevSV(0) doesn't yet have a LEN field. Using newSV_type(SVt_PV) instead fixed the issue (AFAICT), i.e.
... obj = newSV_type(SVt_PV); SvPOK_only( obj ); SvPV_set( obj, vector ); SvLEN_set( obj, bytes ); SvCUR_set( obj, bytes ); ... __END__ $ ./959669.pl 128 ... SV = PVMG(0x1068f90) at 0xfb8d80 REFCNT = 1 FLAGS = (OBJECT,POK,pPOK) IV = 0 NV = 0 PV = 0x149cfa0 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" CUR = 16 LEN = 16 STASH = 0xfd4f08 "fred"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: [I::C] Why does it segfault?
by BrowserUk (Patriarch) on Mar 15, 2012 at 06:08 UTC | |
|
Re^2: [I::C] Why does it segfault?
by ikegami (Patriarch) on Mar 16, 2012 at 21:25 UTC |