#8788: segfault in Sage-4.4 built using GCC-4.5.0
-----------------------+----------------------------------------------------
   Reporter:  was      |       Owner:  GeorgSWeber
       Type:  defect   |      Status:  new        
   Priority:  blocker  |   Milestone:  sage-4.4.1 
  Component:  build    |    Keywords:             
     Author:           |    Upstream:  N/A        
   Reviewer:           |      Merged:             
Work_issues:           |  
-----------------------+----------------------------------------------------

Comment(by wjp):

 Well, this is a fun one. Givaro and Linbox indeed end up destructing the
 same object.

 The destructor is registered once via givaro:

 {{{
 #0  0x00000039a6c35dd0 in __cxa_atexit_internal () from /lib64/libc.so.6
 #1  0x00007fffddf09ec2 in randstate (...)
     at sage-4.4/local//include/gmp++/gmp++_int.inl:317
 #2  seeding (...)
     at sage-4.4/local//include/gmp++/gmp++_int.inl:322
 #3  seeding (...)
     at sage-4.4/local//include/givaro/givinteger.h:132
 #4  IntFactorDom (...)
     at sage-4.4/local//include/givaro/givintfactor.h:43
 #5  IntNumTheoDom (...)
     at sage-4.4/local//include/givaro/givintnumtheo.h:23
 #6  GFqDom<int>::GFqDom (...)
     at sage-4.4/local//include/givaro/givgfq.inl:931
 }}}

 and once via linbox:

 {{{
 #0  0x00000039a6c35dd0 in __cxa_atexit_internal () from /lib64/libc.so.6
 #1  0x00007fffd5dbe365 in randstate (...)
     at sage-4.4/local/include/gmp++/gmp++_int.inl:317
 #2  seeding (...)
     at sage-4.4/local/include/gmp++/gmp++_int.inl:322
 #3  setSeed (...) at ../../linbox/randiter/random-prime.h:57
 #4  LinBox::RandomPrimeIterator::RandomPrimeIterator (this=0x7fffffffc600,
     bits=<value optimized out>, seed=<value optimized out>)
     at ../../linbox/randiter/random-prime.h:26
 }}}

 This might be a compiler and/or linker bug...

 I'm not altogether sure how best to workaround it. One possible way would
 just be to avoid clearing the randstate entirely in givaro's
 {{{Integer::randstate()}}}. If I understand things correctly, there won't
 be more than one copy around for each library using givaro, so it won't
 actually leak memory except on program exit.

 I need to stop looking at this for today, but if anyone wants to test,
 that would require replacing the following in {{{[gmp++_int.inl}}}

 {{{
 inline gmp_randclass& Integer::randstate(long unsigned int seed) {
         static gmp_randclass randstate(GMP_RAND_ALG_DEFAULT,seed);
         return static_cast<gmp_randclass&>(randstate);
 }
 }}}

 by

 {{{
 inline gmp_randclass& Integer::randstate(long unsigned int seed) {
         static gmp_randclass* randstate = new
 gmp_randclass(GMP_RAND_ALG_DEFAULT,seed);
         return *randstate;
 }
 }}}

 An initial quick test shows that this might fix the issue, but I only
 rebuilt linbox after this change; nothing else, not even givaro itself.
 And I only tried the example given in the initial report in the ticket, no
 doctests.

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