Upgrading Sage from 9.2 to 9.3 breaks the
LMFDB (segfaults on startup). We believe that the problem arises from an interaction between Pari and threads, and were able to duplicate it in Sage with the following:
from concurrent.futures import ThreadPoolExecutor
sage: with ThreadPoolExecutor() as e:
....: j = e.submit(is_squarefree, 15)
....: j.result()
...
~/sage/sage-9.4.beta0/local/lib/python3.9/site-packages/sage/rings/integer.pyx in sage.rings.integer.Integer.is_squarefree (build/cythonized/sage/rings/integer.c:37634)()
6007 False
6008 """
-> 6009 return self.__pari__().issquarefree()
6010
6011 cpdef __pari__(self):
~/sage/sage-9.4.beta0/local/lib/python3.9/site-packages/sage/rings/integer.pyx in sage.rings.integer.Integer.__pari__ (build/cythonized/sage/rings/integer.c:37754)()
6029
6030 """
-> 6031 return new_gen_from_mpz_t(self.value)
6032
6033 def _interface_init_(self, I=None):
~/sage/sage-9.4.beta0/local/lib/python3.9/site-packages/sage/libs/pari/convert_gmp.pyx in sage.libs.pari.convert_gmp.new_gen_from_mpz_t (build/cythonized/sage/libs/pari/convert_gmp.c:1298)()
50 True
51 """
---> 52 sig_on()
53 return new_gen(_new_GEN_from_mpz_t(value))
54
SignalError: Segmentation fault
Searching for cypari issues,
#94 suggests that there may be a problem with "relatively recent decision of maintaining pointers on the PARI stack."
At this point, we're a little lost. We understand that sage overall is not threadsafe. But we hope that cypari (and the parts of Sage that we use in the LMFDB) can be, since it was in 9.2. Any tips on where to look next (or fixes to suggest!) would be welcome.
David