[Cython] regarding ticket #810 (segfault in Sage)

Stefan Behnel stefan_ml at behnel.de
Fri Apr 26 07:18:07 CEST 2013


Stefan Behnel, 26.04.2013 07:07:
> looking at this ticket:
> 
> http://trac.cython.org/cython_trac/ticket/810
> 
> and at the underlying Sage ticket:
> 
> http://trac.sagemath.org/sage_trac/ticket/14452
> 
> ISTM that this crash is not actually related to cdef kwargs but simply to
> the fact that the C code is now calling directly through the C layer and no
> longer through Python. The major difference being that Python puts
> arguments into a tuple that is kept alive for the whole timespan of the
> call, whereas C just passes in the reference and forgets about it.
> 
> Since the method in question replaces references internally, it's quite
> possible that it somehow deletes the last reference to the object that was
> passed in. I wouldn't really know why, as we specifically guard against
> these things since somewhere around 0.17 (and comment #7 in the Sage ticket
> shows an example of that), but maybe this is just a corner case that we
> failed to handle so far, or maybe the Sage code is doing something
> 'unexpected' here.

To debug this further, I suggest stepping through the _get_object() method
with a watchpoint set on the reference count of the "owner" object (or
maybe others) to observe when it changes and if it drops down to zero at
some point during that call.

Stefan



More information about the cython-devel mailing list