Changes between Version 25 and Version 75 of Ticket #11339

10/01/11 21:34:09 (10 years ago)

I am setting this bug to Needs Review. The two patches here will correctly refcount the Singular rings, and the reviewer should focus on that aspect. They also make Sage crash because of issues in the libSingular interface. The latter will be dealt with in #10903. Please report any crashes in Sage on #10903, and not here.


  • Ticket #11339

    • Property Cc leif added
    • Property Priority changed from major to critical
    • Property Summary changed from Illegal use of __deallocate__ in cython (pyx) code to Refcounting for Cython rings
    • Property Work issues changed from to Rebase on Sage 4.7.2.alpha2.
  • Ticket #11339 – Description

    v25 v75  
     1= Ref counting for Singular rings =
     3Python makes no guarantees that destructors are called if circular references are involved. This patch implements an extra Python proxy layer that correctly refcounts Singular rings. In contrast to our earlier code, it will release the singular rings once they are no longer in use. This triggers various issues in Sage/libSingular that are dealt with in the follow-up ticket #10903
     5= Historic discussion =
    17As [ described for the Sage on Gentoo project], there is a problem in how parts of sage use `__deallocate__` in their Cython code. I've actually traced an instance of [ groebner_strategy.pyx] causing segmentation faults under Python 2.7.
    511Others have had similar problems before. There are [ crude workarounds] floating around. I guess a proper solution would be twaking cython to allow custom code in the tp_clear function. In other words, have a "magic" mehod `__clear__` similar to the magic `__deallocate__`. But I'll wait for comments here first, before taking this to cython upstream. Perhaps people with more experience have better solutions to offer. And I won't mind if you decide to take this to Cython devs yourselves.
     13= Apply =
    816 * [attachment:trac_11339_refcount_singular_rings.patch]