Segmentation fault in @interact when repeatedly computing polynomial roots in JupyterLab (Sage 10.9)

15 views
Skip to first unread message

Jose Ignacio Burgos Gil

unread,
12:20 PM (10 hours ago) 12:20 PM
to sage-devel
I think I have found a bug that has not been reported already. Here is a description of it.  (with chatgpt help)

### Summary 
 Using `@interact` in a JupyterLab notebook, repeatedly computing polynomial roots causes a segmentation fault on the second interaction (moving a slider or toggling a checkbox). The same computations are completely stable outside `@interact`, including repeated execution in ordinary Python loops. The problem is reproducible both with the Arch Linux package of Sage 10.9 and with the official Sage 10.9 Docker image. 
 ### Environment (arch linux)
 Sage version: 10.9 
 Python: 3.14.5 (Arch package) (The same behaviour is observed in the official Sage 10.9 Docker image.) 
 JupyterLab: 4.5.8 
 ipywidgets: 8.1.8 
 ipykernel: 7.3.0 
 Operating system: Manjaro Linux (also reproduced in the official Sage Docker image) 
### Environment (docker)
Sage: SageMath version 10.9, Release Date: 2026-05-04
JupyterLab: 4.5.6
ipywidgets: 8.1.8
ipykernel: 7.2.0
Notebook: 7.5.5

 ### Minimal reproducer 
 ```python 
from sage.rings.polynomial.complex_roots 
import complex_roots 
 x = polygen(ZZ) 
 @interact def f(n=slider(3,100)): 
     p = x^20 + x + 1 
     print(len(complex_roots(p))) 
``` 

 The first execution succeeds. Changing the slider once causes Sage to terminate with a segmentation fault. The same behaviour is obtained with 
 ```python 
p.change_ring(CC).roots() 
``` 
 instead of 
 ```python 
complex_roots(p) 
``` 
 ### Expected behaviour 
 The callback should execute repeatedly without crashing. 
 ### Actual behaviour 
 The kernel terminates with a segmentation fault after the second callback invocation. ### Additional experiments 
 The following all execute correctly without any segmentation fault: 
 1. Ordinary execution: 
 ```python 
p = x^20 + x + 1 complex_roots(p) 
``` 
 2. Repeated execution: 
 ```python 
for i in range(100): 
     complex_roots(x^20 + x + 1) 
``` 
 3. Using  
```python 
p.change_ring(CC).roots() 
``` 
 outside `@interact`. 
 4. A plain `ipywidgets.observe` callback: 
 ```python 
import ipywidgets as widgets 
from IPython.display import display 
 s = widgets.IntSlider() 
display(s) 
 def cb(change): 
     p = x^20 + x + 1 
     print(len(complex_roots(p))) 
     s.observe(cb, names="value") 
``` 
 This callback can be executed repeatedly without any crash. The segmentation fault therefore appears to be specific to Sage's `@interact` machinery (or its interaction with JupyterLab), rather than to the root-finding routines themselves. 
 ### Notes The issue was first observed on the Arch Linux package of Sage 10.9, but it is also reproducible in the official Sage 10.9 Docker image, suggesting that it is not specific to the Arch packaging.


dmo...@deductivepress.ca

unread,
5:41 PM (4 hours ago) 5:41 PM
to sage-devel
Github issue #42567 has been opened for this, so please post responses there.
Reply all
Reply to author
Forward
0 new messages