> Em 1 de junho de 2011 18:22, Paulo César Pereira de Andrade
> 
> <paulo.cesar.pereira.de.andr...@gmail.com> escreveu:
> >  If I understand it correctly, at least for this particular case:
> > 
> > sage/libs/singular/groebner_strategy.pyx:GroebnerStrategy(SageObject)._pa
> > rent =>
> > sage/rings/polynomial/multi_polynomial_libsingular.pyx:MPolynomialRing_l
> > ibsingular(MPolynomialRing_generic)
> > 
> > and the _parent field has a __dealloc__ as:
> > singular_ring_delete(self._ring) while the GroebnerStrategy
> > __dealloc__ deferences _parent._ring.
> > 
> >  So, again if I understand correctly, the crash is happening because
> > MPolynomialRing_libsingular:__deallocate__ should be called
> > after pyx:GroebnerStrategy:__deallocate__, but in python 2.7
> > this is not happening, as the order is not guaranteed, and
> > apparently just happens to be in the correct order with
> > python 2.6.
> 
>   Sorry for replying to myself, but actually, it should be quite
> simple to have it functional, just that it must be done in a case
> by case approach. Something like:
> 
> GroebnerStrategy():
>     __new__:
>         ...
>         the_ring_handle = ...
>         incref(the_ring_handle)
>     __del__:
>         ...
>         decref(the_ring_handle)
>         del the_ring_handle ## requirement of this depends on semantics
> 
> MPolynomialRing_libsingular():
>     __new__:
>         ...
>         the_ring_ptr = ...
>     __del__:
>         if (refcnt(self) <= 0) ## how to do this in python? check if
> == 1? or do not use python reference counter?
>             free(the_ring_ptr)
> 
>   This should be easy for python internal experts to
> implement (I can try to experiment with that, but I do
> not know much of python and only do mark&sweep :-)
> 
Quoting Volker:
Just to clarify, right now Cython extension classes do not call the Python 
destructor __del__ upon finalization, so Sage can't rely on this mechanism. I'm 
not quite sure if it is an intentional thing or if the Cython devs just 
haven't gotten around to implementing it.

So we need cython to catch up with that one.

Francois

This email may be confidential and subject to legal privilege, it may
not reflect the views of the University of Canterbury, and it is not
guaranteed to be virus free. If you are not an intended recipient,
please notify the sender immediately and erase all copies of the message
and any attachments.

Please refer to http://www.canterbury.ac.nz/emaildisclaimer for more
information.

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to