<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.10.2">
</HEAD>
<BODY>
Anybody on the list run into this problem?<BR>
<BR>
-------- Forwarded Message --------<BR>
<B>From</B>: Scott T. Hildreth &lt;<A HREF="mailto:%22Scott%20T.%20Hildreth%22%20%3cshildret@scotth.emsphone.com%3e">shildret@scotth.emsphone.com</A>&gt;<BR>
<B>Reply-To</B>: <A HREF="mailto:shildreth@allantgroup.com">shildreth@allantgroup.com</A><BR>
<B>To</B>: Perl-Xs &lt;<A HREF="mailto:Perl-Xs%20%3cperl-xs@perl.org%3e">perl-xs@perl.org</A>&gt;<BR>
<B>Subject</B>: Re: 64 bit problems - XS wrappers<BR>
<B>Date</B>: Thu, 13 Jul 2006 18:49:14 -0500<BR>
<BR>
<PRE>
On Thu, 2006-07-13 at 18:32 -0500, Scott T. Hildreth wrote:
&gt; I changed the XS declaration to a SV * and changed,
&gt; 
&gt;    RETVAL = (char *)fmt_get_fld_location(fmt, fld);
&gt; 
&gt;    to  RETVAL = (SV *)fmt_get_fld_location(fmt, fld)
&gt; 
&gt; ...and in gdb I could see more, 
&gt; 
&gt; (gdb) n
&gt; 1197                IV tmp = SvIV((SV*)SvRV(ST(1)));
&gt; (gdb) n
&gt; 419             RETVAL = (SV *)fmt_get_fld_location(fmt, fld);
&gt; (gdb) n
&gt; 1205            ST(0) = RETVAL;
&gt; (gdb) p RETVAL
&gt; No symbol &quot;RETVAL&quot; in current context.
&gt; (gdb) n
&gt; 1206            sv_2mortal(ST(0));
&gt; (gdb) p ST(0)
&gt; $6 = (SV *) 0x600ea0
&gt; (gdb) p *ST(0)

       ...okay this doesn't tell me anything.  I got the same result on
for another function call, which does not seg fault.  It also returns a 
(char *) and works.  I'm stumped.  If I step into the function I see the
null string is created and the returned.  I don't know how to see if it 
is in the RETVAL

&gt; $7 = {sv_any = 0x0, sv_refcnt = 2147482504, sv_flags = 8388608}
&gt; 
&gt; 
&gt;       ...shouldn't sv_any not be null?
&gt; 
&gt; (gdb) n
&gt; 
&gt; Program received signal SIGSEGV, Segmentation fault.
&gt; 0x0000000000473459 in Perl_sv_2mortal ()
&gt; 
&gt; 
&gt; On Thu, 2006-07-13 at 17:15 -0500, Scott T. Hildreth wrote:
&gt; &gt; Posting again, didn't see it show up on the list.
&gt; &gt; 
&gt; &gt; ..I've seen the strlen() seg fault problem by searching, 
&gt; &gt; just no solutions.  The string returned in RETVAL is null terminated, 
&gt; &gt; so I don't understand.  
&gt; &gt; 
&gt; &gt; 
&gt; &gt; On Thu, 2006-07-13 at 14:56 -0500, Scott T. Hildreth wrote:
&gt; &gt; &gt; ...we are installing 64bit Suse boxes.  I normally compile our own Perl,
&gt; &gt; &gt; leaving the vendor Perl alone.  I don't think this will help with this 
&gt; &gt; &gt; problem though (unless I compile as 32 bit).  The following XS code
&gt; &gt; &gt; fails in libc - strlen(),
&gt; &gt; &gt; 
&gt; &gt; &gt; =============================================================================
&gt; &gt; &gt; 
&gt; &gt; &gt; 1180    {
&gt; &gt; &gt; (gdb) n
&gt; &gt; &gt; 1181        dXSARGS;
&gt; &gt; &gt; (gdb) n
&gt; &gt; &gt; 1182        if (items != 2)
&gt; &gt; &gt; (gdb) n
&gt; &gt; &gt; 1188            dXSTARG;
&gt; &gt; &gt; (gdb) n
&gt; &gt; &gt; 1190            if (sv_derived_from(ST(0), &quot;FMTPtr&quot;)) {
&gt; &gt; &gt; (gdb) n
&gt; &gt; &gt; 1191                IV tmp = SvIV((SV*)SvRV(ST(0)));
&gt; &gt; &gt; (gdb) n
&gt; &gt; &gt; 1197            if (sv_derived_from(ST(1), &quot;FMT_FLDPtr&quot;)) {
&gt; &gt; &gt; (gdb) n
&gt; &gt; &gt; 1198                IV tmp = SvIV((SV*)SvRV(ST(1)));
&gt; &gt; &gt; (gdb) n
&gt; &gt; &gt; 419             RETVAL = (char *)fmt_get_fld_location(fmt, fld);
&gt; &gt; &gt; (gdb) p tmp
&gt; &gt; &gt; $4 = 11516288
&gt; &gt; &gt; (gdb) n 
&gt; &gt; &gt; 1206            sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
&gt; &gt; &gt; (gdb) p RETVAL
&gt; &gt; &gt; No symbol &quot;RETVAL&quot; in current context.
&gt; &gt; &gt; (gdb) s
&gt; &gt; &gt; 419             RETVAL = (char *)fmt_get_fld_location(fmt, fld);
&gt; &gt; &gt; (gdb) s
&gt; &gt; &gt; 1206            sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
&gt; &gt; &gt; (gdb) s
&gt; &gt; &gt; 
&gt; &gt; &gt; Program received signal SIGSEGV, Segmentation fault.
&gt; &gt; &gt; 0x00002ad1795286d0 in strlen () from /lib64/libc.so.6
&gt; &gt; &gt; 
&gt; &gt; &gt; =================================================================================
&gt; &gt; &gt; 
&gt; &gt; &gt; ...at first I thought it was the threaded-64 bit Perls, but it seg
&gt; &gt; &gt; faults  on a non-threaded version as well.  It runs fine on a 32 bit 
&gt; &gt; &gt; server.  
&gt; &gt; &gt; 
&gt; &gt; &gt; I am really hopping someone has run into this, any help would be much
&gt; &gt; &gt; appreciated.
&gt; &gt; &gt; 
&gt; &gt; &gt; 
&gt; &gt; &gt;                                       STH
&gt; &gt; &gt; 
&gt; &gt; &gt; 
&gt; &gt; &gt; 
&gt; &gt; &gt;&nbsp; 
</PRE>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
-- <BR>
Scott T. Hildreth &lt;<A HREF="mailto:shild@sbcglobal.net">shild@sbcglobal.net</A>&gt;
</TD>
</TR>
</TABLE>
</BODY>
</HTML>