Segmentation Fault

235 views
Skip to first unread message

dwb...@gmail.com

unread,
May 29, 2023, 4:07:50 PM5/29/23
to sage-devel
I was shown the following way of getting a segmentation fault in Sage.

sage: var("q A")
sage: p = A*(1+1/A)-A-1
sage: (q^p).full_simplify()

This consistently causes a crash. The person who found it was doing some actual work, got a crash, and boiled it down to a minimal example.

Daniel Bump

Nils Bruin

unread,
May 29, 2023, 7:51:28 PM5/29/23
to sage-devel
Localized a bit further:

var("q A")
p = A*(1+1/A)-A-1
V=(q^p)._maxima_().rectform()

after this, V._sage_() crashes, and I think it's the same crash as above.

Transcribing what V is in maxima, we get:

I*sin(atan2(0,q)*((1/A+1)*A-A-1))*abs(q)^((1/A+1)*A-A-1)+cos(atan2(0,q)*((1/A+1)*A-A-1))*abs(q)^((1/A+1)*A-A-1)

which indeed causes a crash when input directly into sage. More simply:

var("q A")
U=atan2(0,q)*((1/A+1)*A-A-1)
sin(U)     #this crashes

It looks like an infinite recursion, so probably the constructor (of sin?) tries to do some simplification, which ends up trying to construct the same expression again. The traceback implicates Pynac.

dmo...@deductivepress.ca

unread,
May 30, 2023, 12:00:05 AM5/30/23
to sage-devel
I'm surprised that this hasn't been reported previously, because we can get a crash even without atan or any division:

sin( x*(x+1) - x^2 - x )  # this crashes sage

This also crashes with sinh or cos or tan in the place of sin, but not with exp or log. 

PS I verified on CoCalc that this is not a new bug: this crashes version 9.1.

dmo...@deductivepress.ca

unread,
May 30, 2023, 8:23:16 PM5/30/23
to sage-devel
I opened issue #35696 for this, and put a diagnosis there.
Reply all
Reply to author
Forward
0 new messages