#13447: Make libsingular multivariate polynomial rings collectable
----------------------------------------------------------------+-----------
       Reporter:  nbruin                                        |         
Owner:                                                                          
 
           Type:  defect                                        |        
Status:  needs_work                                                             
  
       Priority:  major                                         |     
Milestone:  sage-5.4                                                            
     
      Component:  memleak                                       |    
Resolution:                                                                     
      
       Keywords:                                                |   Work 
issues:  Understand why sometimes `new_RingWrap` needs an incref and sometimes 
not
Report Upstream:  None of the above - read trac for reasoning.  |     
Reviewers:  Simon King                                                          
     
        Authors:  Nils Bruin, Simon King                        |     Merged 
in:                                                                           
   Dependencies:  #11521                                        |      
Stopgaps:                                                                       
    
----------------------------------------------------------------+-----------

Comment (by SimonKing):

 I have posted a new patch
 [attachment:trac_13447-attempted_improvement.patch]. According to Hans, it
 may happen that Singular functions return NULL, which means that there has
 been an error. Therefore, I suggest to actually ''raise'' a `RuntimeError`
 if the return value is NULL. Apart from that, I postpone another `ggetid`
 call to a location where `currRing` is guaranteed to exist; however,
 according to Hans, that call to `ggetid` (namely in the case of a library
 functions) should be fine also without `currRing`.

 Here is the problem:
 {{{
 sage -t --verbose
 devel/sage/sage/rings/polynomial/multi_polynomial_ideal.py
 ...
 Trying:
     R = QQ['a, b']; (a, b,) = R._first_ngens(2); I =
 R.ideal(a**Integer(2)+b**Integer(2)-Integer(1))###line 3581:_sage_    >>>
 R.<a,b> = QQ[]; I = R.ideal(a^2+b^2-1)
 Expecting nothing
 ok
 Trying:
     Q = QuotientRing(R,I); K = Frac(Q)###line 3582:_sage_    >>> Q =
 QuotientRing(R,I); K = Frac(Q)
 Expecting nothing
 // ** char_series returns 0 x 0 matrix from 2 input polys (0)
 I[1,1]=b2+a2-1*** *** Error: TIMED OUT! PROCESS KILLED! *** ***

          [360.3 s]
 }}}

 I have absolutely no idea why that happens.

 The error occurs in the Singular library function `primdecSY`. I did check
 that `currRing` is definitely not NULL when calling the function,
 `currRingHdl.data.uring==currRing`, and there are plenty of references to
 `currRing`. Moreover, the error does not occur if one copies the whole
 example (which is from the groebner_basis method) into an interactive
 session.

 `primdecSY` hangs, there is no return value (not even NULL).

 Since there is no segfault, I guess gdb would not help here. Since
 currRing is referenced several times, I guess that it has not been double-
 freed - but who knows? Can it be that a ring was double-freed, then a new
 ring was created in the same location, and then an error occurs when
 working with that new ring?

 For now:

 Apply trac_13447-sanitise_ring_refcount.patch
 trac_13447-attempted_improvement.patch

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13447#comment:80>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to