#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 found something fishy with the refcount during
 `sage.libs.singular.function.call_function`.

 I changed the code as follows:
 {{{

     # In the Singular interpreter, we must ensure that currRing->ref > 0.
     si_ring.ref += 1
     cdef int orig_ref = si_ring.ref   # CHANGE: store the reference count
     try:
         with opt_ctx: # we are preserving the global options state here
             if signal_handler:
                 sig_on()
                 _res = self.call_handler.handle_call(argument_list,
 si_ring)
                 sig_off()
             else:
                 _res = self.call_handler.handle_call(argument_list,
 si_ring)

         if myynest:
             myynest = 0

         if currentVoice:
             currentVoice = NULL

         if errorreported:
             errorreported = 0
             raise RuntimeError("Error in Singular function call '%s':\n
 %s"%
                 (self._name, "\n ".join(error_messages)))
         if si_ring.ref!=orig_ref:  # CHANGE: Test if Singular has changed
 the refcount
             ff = file("/Users/SimonKing/blubber","a")
             ff.write( "Here is something fishy!\n")
             ff.close()

         res = argument_list.to_python(_res)
         ...
 }}}

 When running the failing `sage -t
 devel/sage/sage/rings/polynomial/multi_polynomial_ideal.py`, the refcount
 changes exactly once before the test hangs.

 It is definitely not supposed to happen that Singular changes the refcount
 of `currRing`. Changes in the ref counter should only happen in the next
 line, when the results are converted to python (any polynomial will
 increase the refcount by one).

 I don't know yet what function is causing the trouble - but I hope I'll
 find out soon...

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13447#comment:82>
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