Ticket #13447: trac_13447-double_refcount.patch

File trac_13447-double_refcount.patch, 1.8 KB (added by nbruin, 10 years ago)

take into account both refcount_dict and ring*.ref fields on deletion.

  • sage/libs/singular/ring.pyx

    # HG changeset patch
    # User Nils Bruin <nbruin@sfu.ca>
    # Date 1347727766 25200
    # Node ID b1ff7bd7a86709a2271e26789fad63d0187b4f15
    # Parent  700061226df5b343889aa4744f2376d351523dc0
    #13447: make delete_singular_ring take into account both the ring_refcount_dict refcount and singular's own doomed.ref refcount field. The two should probably be consolidated.
    diff --git a/sage/libs/singular/ring.pyx b/sage/libs/singular/ring.pyx
    a b include "../../ext/stdsage.pxi" 
    1919from sage.libs.gmp.types cimport __mpz_struct
    2020from sage.libs.gmp.mpz cimport mpz_init_set_ui, mpz_init_set
    22 from sage.libs.singular.decl cimport number, lnumber, napoly, ring, currRing
     22from sage.libs.singular.decl cimport number, lnumber, napoly, ring, currRing, currRingHdl
    2323from sage.libs.singular.decl cimport rChangeCurrRing, rCopy0, rComplete, rDelete
    2424from sage.libs.singular.decl cimport omAlloc0, omStrDup, omAlloc, omAlloc0Bin,  sip_sring_bin, rnumber_bin
    2525from sage.libs.singular.decl cimport ringorder_dp, ringorder_Dp, ringorder_lp, ringorder_rp, ringorder_ds, ringorder_Ds, ringorder_ls, ringorder_M, ringorder_C, ringorder_wp, ringorder_Wp, ringorder_ws, ringorder_Ws, ringorder_a
    from sage.rings.polynomial.polynomial_ri 
    4141from sage.misc.misc_c import is_64_bit
     43import sys
    4445# mapping str --> SINGULAR representation
    4546order_dict = {
    cdef void singular_ring_delete(ring *doo 
    537538    cdef ring_wrapper_Py r = wrap_ring(doomed)
    538539    refcount = ring_refcount_dict.pop(r)
    539     if refcount > 1:
     540    sys.stderr.write('ring delete called with recounts=%d and ref=%d\n'%(refcount,doomed.ref))
     541    if refcount > 1 or doomed.ref > 0:
    540542        ring_refcount_dict[r] = refcount-1
    541543        return