Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: [I::C] Why does it segfault?

by Eliya (Vicar)
on Mar 15, 2012 at 03:46 UTC ( [id://959704]=note: print w/replies, xml ) Need Help??


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

    Thanks Eliya. Makes sense... Now :)


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

Re^2: [I::C] Why does it segfault?
by ikegami (Patriarch) on Mar 16, 2012 at 21:25 UTC

    My guess would be this is because the SV created with nevSV(0) doesn't yet have a LEN field.

    It doesn't have a body at all.

    Using newSV_type(SVt_PV) instead fixed the issue (AFAICT), i.e.

    Shorter: [ nevermind, that'll copy the vector instead of uisng it. ]

    newSVpvn(vector, bytes)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://959704]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-23 06:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found