bus error

View: New views
3 Messages — Rating Filter:   Alert me  

bus error

by grossetti :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hello everyone,

I keep on getting a "bus error" when I activate this in my .i :

%typemap(out) true_or_false {
    if($1 <= 0)
        $result = Py_False;
    else
        $result = Py_True;
}

where true_or_false is defined in my .h as :

typedef int true_or_false;

but if I comment it out (and adjust the conditions in the test code) I no
longer get it. Does anyone have an idea why this happens? It doesn't
happen on the first call, just kind of randomly.

Thank you, Gabriel

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

Re: bus error

by Josh Cherry :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Mon, 21 Sep 2009, gabriel.rossetti@... wrote:

> I keep on getting a "bus error" when I activate this in my .i :
>
> %typemap(out) true_or_false {
>    if($1 <= 0)
>        $result = Py_False;
>    else
>        $result = Py_True;
> }
>
> where true_or_false is defined in my .h as :
>
> typedef int true_or_false;
>
> but if I comment it out (and adjust the conditions in the test code) I no
> longer get it. Does anyone have an idea why this happens? It doesn't
> happen on the first call, just kind of randomly.

Probably because you're not adjusting the reference counts on the Python
objects.

Josh


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

Re: bus error

by grossetti :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Josh Cherry wrote:

>
>
> On Mon, 21 Sep 2009, gabriel.rossetti@... wrote:
>
>> I keep on getting a "bus error" when I activate this in my .i :
>>
>> %typemap(out) true_or_false {
>>    if($1 <= 0)
>>        $result = Py_False;
>>    else
>>        $result = Py_True;
>> }
>>
>> where true_or_false is defined in my .h as :
>>
>> typedef int true_or_false;
>>
>> but if I comment it out (and adjust the conditions in the test code)
>> I no
>> longer get it. Does anyone have an idea why this happens? It doesn't
>> happen on the first call, just kind of randomly.
>
> Probably because you're not adjusting the reference counts on the
> Python objects.
>
> Josh
>
so I should do something like this :

%typemap(out) true_or_false {
    if($1 <= 0)
        $result = Py_False;
    else
        $result = Py_True;
    Py_CLEAR($1);
    Py_INCREF($result);
}

Gabriel


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user