Re: Problem with building XS module on AS 1401

[email protected] (Steffen Mueller)
Newsgroups perl.xs
Message-ID <[email protected]>
On 08/07/2011 11:59 PM, Erland Sommarskog wrote:
>     int
>     executebatch(sqlsrv, rows_affected = NULL)
>      SV * sqlsrv;
>      SV * rows_affected;
>
> In one place in one test script, this XS routine returns undef. This is a
> core routine, so it is called well over thousand times in the test suite.
> And in one specific case it returns undef. I've traced it so far that the
> underlying C++ function does really execute to the end and returns TRUE.
>
> Apparently something goes wrong in the part that comes after? Why? Maybe
> something was clobbered, so maybe I have a bad pointer somewhere. But
> they usually cause a lot more problem than a single miss in 1000 executions.
>
> Anyway, that's why I stick with -O2.

Check the C code generated by xsubpp. Then insert ludicrous amounts of 
printf()'s into the code that comes after the actual C++ function 
invocation.

Since you're passing around SV*'s the bug might be in the code that you 
wrote to handle the Perl datastructures if it's more than just a simple 
SvIV on rows_affected or SvPV_nolen() on sqlsrv. Sometimes, the time of 
destruction of "mortal"s may not be what you expect (generally during 
nextstate ops, though), so if you have a mortal SV that gets destroyed 
early... err. No. Then you typically get a segmentation fault, not an 
SV* that just happens to point at &PL_sv_undef. Nevermind my drivel. :)

Hope this helps a little bit.
Steffen
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.