On Thu, Aug 11, 2005 at 11:55:49AM +0800, Dongxu Ma wrote:

> According to typemap in ExtUtils and perl.h, casting IV to pointer
> should be safe in this case, since on my machine(32bit, kernel
> 2.6.12), sizeof(int) == 4, which is the same as a  pointer. Does
> anyone have any idea about this issue?

I think that there's a bug in the typemap you're using:

> -------------------------typemap-------------------------------
> TYPEMAP
> Test *                T_OBJECT
> 
> ################
> INPUT
> T_OBJECT
>       if(sv_isa($arg, \"Test\") && sv_isobject($arg)) {
>               $var = INT2PTR($type, SvIV($arg));

                                      SvIV(SvRV($arg))
>       } else {
>               warn(\"$arg is not a blessed object\");
>               XSRETURN_UNDEF;
>       }


If I make the above change to use SvRV then I can avoid getting a segfault.

Nicholas Clark

Reply via email to