How to trace Maxima failures

asked 2017-07-14 14:37:51 -0500

Richard_L gravatar image

updated 2017-07-20 17:11:43 -0500

I often hit the "Detected access to protected memory ..." failure from maxima. In some cases it seems to go into a loop whereupon I receive the same message hundreds of times. I know which sage worksheet cell is failing, but cannot find what it is about that cell which causes the failure, because maxima does not tell me. Is it possible to set up the worksheet so that this error is trapped and triggers a stack trace in sage/python?

sage: version()  
'SageMath version 7.6, Release Date: 2017-03-25'  
sage: Parallelism().set(nproc=2)  
sage: var('rho12,rho13,rho23', domain='real')  
sage: assume(rho12>0, rho13>0, rho23>0)  
sage: var('r12,r13,r23', domain='real')  
sage: var('m1 m2 m3', domain='real')  
sage: var('mu12,mu13,mu23', domain='real')

sage: ####  
sage: #assume(m1>0, m2>0, m3>0)  # !! This is a Maxima killer (even though physically required)! 
sage: m1=1; m2=1; m3=1     
sage: # !! With 'assume' above and with ANY m1,m2,m3 in SR, we seg-fault and core-dump when computing the connection.  
sage: ####  

sage: mu12 = (m1*m2)/(m1+m2); mu23 = (m2*m3)/(m2+m3); mu13 = (m1*m3)/(m1+m3)  
sage: # Contravariant metric tensor, per Turbiner et al., arXiv:1611.08157.  
sage: Ginv = matrix([[2/mu12*rho12, 1/m1*(rho12+rho13-rho23), 1/m2*(rho12+rho23-rho13)],\  
...           [1/m1*(rho12+rho13-rho23), 2/mu13*rho13, 1/m3*(rho13+rho23-rho12)],\  
...           [1/m2*(rho12+rho23-rho13), 1/m3*(rho13+rho23-rho12), 2/mu23*rho23]])  
sage: G = Ginv.inverse();  
sage: # Begin manifold creation  
sage: M = Manifold(1*3,'R^3',field='real',start_index=1)  
sage: U = M.open_subset('U')  
sage: Rho.<rho12,rho13,rho23> = U.chart();  
sage: Rho.add_restrictions([rho12>0, rho13>0, rho23>0])  
sage: Rho.add_restrictions([sqrt(rho23)<sqrt(rho12)+sqrt(rho13),\  
...       sqrt(rho13)<sqrt(rho12)+sqrt(rho23), sqrt(rho12)<sqrt(rho13)+sqrt(rho23)])  
sage: g = M.riemannian_metric('g');  
sage: g[:] = G[:].simplify_full()  
sage: ginv = g.inverse()  

sage: ### This will seg-fault and core-dump if ANY m1,m2,m3 are in SR, and the 'assume' statement active.  
sage: nabla = g.connection()

sage: # Turbiner calculates the Ricci scalar.  
sage: ### Attempting to do so here causes seg fault if all m1,m2,m3=1!   
sage: #  (Is this because of singularities at all boundaries of rho-space? 
sage: # (Regardless, code should *never* crash.)  
sage: Ric_g = g.ricci_scalar()
edit retag flag offensive close merge delete


could you provide a minimal code snippet that triggers the error?

vdelecroix gravatar imagevdelecroix ( 2017-07-14 16:40:22 -0500 )edit

Correction: Wait long enough and it eventually dumps core. The dump is huge, 16 GB, even though the pgm is probably not using all that. Unfortunately, I don't have all the debugging libraries installed, so gdb can only tell me what we already know, that the seg-fault occurred in the ecl library. The shortest snippet I can make is ~40 lines. Notice that two seg-faults are possible from this code, depending on which lines are (un)commented.

Richard_L gravatar imageRichard_L ( 2017-07-19 18:24:28 -0500 )edit