Sage is crashing.

Sage won’t work. I need to utilize it to do some breaking of textbook RSA implementation for a CTF I’m competing in. At least I’m 99% sure that it’s just textbook RSA and I didn’t feel like doing the math myself when sage exists.


Subject: ipython: Sage crashes on startup due to IPython issue.
Package: ipython
Version: 5.8.0-1
Severity: important

Dear Maintainer,

Parrot is building from debian testing and I’m going to report the issue to them also in case someone else hasn’t tried the latest version of sage.
I ran sage from the terminal, then it said that ipython crashed, and gave me the bugreport. I know that GIMP is currently unable to be utilized in debian testing but I couldn’t find anything about sage.

– System Information:
Distributor ID: Parrot
Description: Parrot GNU/Linux 4.7
Release: 4.7
Codename: n/a
Architecture: x86_64

Kernel: Linux 5.1.0-parrot1-3t-amd64 (SMP w/12 CPU cores)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_USER, TAINT_OOT_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages ipython depends on:
ii python-ipython 5.8.0-1

ipython recommends no packages.

ipython suggests no packages.

– no debconf information


IPython post-mortem report

{‘commit_hash’: u’033ab93c7’,
‘commit_source’: ‘installation’,
‘default_encoding’: ‘UTF-8’,
‘ipython_path’: ‘/usr/lib/python2.7/dist-packages/IPython’,
‘ipython_version’: ‘5.8.0’,
‘os_name’: ‘posix’,
‘platform’: ‘Linux-5.1.0-parrot1-3t-amd64-x86_64-with-Parrot-4.7-stable’,
‘sys_executable’: ‘/usr/bin/python2’,
‘sys_platform’: ‘linux2’,
‘sys_version’: ‘2.7.16+ (default, Sep 4 2019, 08:19:57) \n[GCC 9.2.1 20190827]’}



Crash traceback:



AttributeError                             Python 2.7.16+: /usr/bin/python2
                                                   Fri Oct  4 09:30:19 2019
A problem occurred executing Python code.  Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.
/usr/share/sagemath/bin/sage-ipython in <module>()
      1 #!/usr/bin/env sage-python23
      2 # -*- coding: utf-8 -*-
      3 """
      4 Sage IPython startup script.
      5 """
      6 
      7 # Display startup banner. Do this before anything else to give the user
      8 # early feedback that Sage is starting.
      9 from sage.misc.banner import banner
     10 banner()
     11 
     12 from sage.repl.interpreter import SageTerminalApp
     13 
     14 app = SageTerminalApp.instance()
---> 15 app.initialize()
        global app.initialize = <bound method SageTerminalApp.initialize of <sage.repl.interpreter.SageTerminalApp object at 0x7ff53e5b8990>>
     16 app.start()

<decorator-gen-110> in initialize(self=<sage.repl.interpreter.SageTerminalApp object>, argv=None)

/usr/lib/python2.7/dist-packages/traitlets/config/application.pyc in catch_config_error(method=<function initialize>, app=<sage.repl.interpreter.SageTerminalApp object>, *args=(None,), **kwargs={})
     72     TRAITLETS_APPLICATION_RAISE_CONFIG_FILE_ERROR = False
     73 else:
     74     raise ValueError("Unsupported value for environment variable: 'TRAITLETS_APPLICATION_RAISE_CONFIG_FILE_ERROR' is set to '%s' which is none of  {'0', '1', 'false', 'true', ''}."% _envvar )
     75 
     76 
     77 @decorator
     78 def catch_config_error(method, app, *args, **kwargs):
     79     """Method decorator for catching invalid config (Trait/ArgumentErrors) during init.
     80 
     81     On a TraitError (generally caused by bad config), this will print the trait's
     82     message, and exit the app.
     83 
     84     For use on init methods, to prevent invoking excepthook on invalid input.
     85     """
     86     try:
---> 87         return method(app, *args, **kwargs)
        method = <function initialize at 0x7ff53d90e550>
        app = <sage.repl.interpreter.SageTerminalApp object at 0x7ff53e5b8990>
        args = (None,)
        kwargs = {}
     88     except (TraitError, ArgumentError) as e:
     89         app.print_help()
     90         app.log.fatal("Bad config encountered during initialization:")
     91         app.log.fatal(str(e))
     92         app.log.debug("Config at the time: %s", app.config)
     93         app.exit(1)
     94 
     95 
     96 class ApplicationError(Exception):
     97     pass
     98 
     99 
    100 class LevelFormatter(logging.Formatter):
    101     """Formatter with additional `highlevel` record
    102 

/usr/lib/python2.7/dist-packages/IPython/terminal/ipapp.pyc in initialize(self=<sage.repl.interpreter.SageTerminalApp object>, argv=None)
    301 
    302         return super(TerminalIPythonApp, self).parse_command_line(argv)
    303     
    304     @catch_config_error
    305     def initialize(self, argv=None):
    306         """Do actions after construct, but before starting the app."""
    307         super(TerminalIPythonApp, self).initialize(argv)
    308         if self.subapp is not None:
    309             # don't bother initializing further, starting subapp
    310             return
    311         # print self.extra_args
    312         if self.extra_args and not self.something_to_run:
    313             self.file_to_run = self.extra_args[0]
    314         self.init_path()
    315         # create the shell
--> 316         self.init_shell()
        self.init_shell = <bound method SageTerminalApp.init_shell of <sage.repl.interpreter.SageTerminalApp object at 0x7ff53e5b8990>>
    317         # and draw the banner
    318         self.init_banner()
    319         # Now a variety of things that happen after the banner is printed.
    320         self.init_gui_pylab()
    321         self.init_extensions()
    322         self.init_code()
    323 
    324     def init_shell(self):
    325         """initialize the InteractiveShell instance"""
    326         # Create an InteractiveShell instance.
    327         # shell.display_banner should always be False for the terminal
    328         # based app, because we call shell.show_banner() by hand below
    329         # so the banner shows *before* all extension loading stuff.
    330         self.shell = self.interactive_shell_class.instance(parent=self,
    331                         profile_dir=self.profile_dir,

/usr/lib/python2.7/dist-packages/sage/repl/interpreter.pyc in init_shell(self=<sage.repl.interpreter.SageTerminalApp object>)
    745         self.shell.has_sage_extensions = SAGE_EXTENSION in self.extensions
    746 
    747         # Load the %lprun extension if available
    748         try:
    749             import line_profiler
    750         except ImportError:
    751             pass
    752         else:
    753             self.extensions.append('line_profiler')
    754 
    755         if self.shell.has_sage_extensions:
    756             self.extensions.remove(SAGE_EXTENSION)
    757 
    758             # load sage extension here to get a crash if
    759             # something is wrong with the sage library
--> 760             self.shell.extension_manager.load_extension(SAGE_EXTENSION)
        self.shell.extension_manager.load_extension = <bound method ExtensionManager.load_extension of <IPython.core.extensions.ExtensionManager object at 0x7ff53ce6f990>>
        global SAGE_EXTENSION = 'sage'
    761 
    762 

/usr/lib/python2.7/dist-packages/IPython/core/extensions.pyc in load_extension(self=<IPython.core.extensions.ExtensionManager object>, module_str='sage')
     70 
     71         Returns the string "already loaded" if the extension is already loaded,
     72         "no load function" if the module doesn't have a load_ipython_extension
     73         function, or None if it succeeded.
     74         """
     75         if module_str in self.loaded:
     76             return "already loaded"
     77         
     78         from IPython.utils.syspathcontext import prepended_to_syspath
     79         
     80         with self.shell.builtin_trap:
     81             if module_str not in sys.modules:
     82                 with prepended_to_syspath(self.ipython_extension_dir):
     83                     __import__(module_str)
     84             mod = sys.modules[module_str]
---> 85             if self._call_load_ipython_extension(mod):
        self._call_load_ipython_extension = <bound method ExtensionManager._call_load_ipython_extension of <IPython.core.extensions.ExtensionManager object at 0x7ff53ce6f990>>
        mod = <module 'sage' from '/usr/lib/python2.7/dist-packages/sage/__init__.pyc'>
     86                 self.loaded.add(module_str)
     87             else:
     88                 return "no load function"
     89 
     90     def unload_extension(self, module_str):
     91         """Unload an IPython extension by its module name.
     92 
     93         This function looks up the extension's name in ``sys.modules`` and
     94         simply calls ``mod.unload_ipython_extension(self)``.
     95         
     96         Returns the string "no unload function" if the extension doesn't define
     97         a function to unload itself, "not loaded" if the extension isn't loaded,
     98         otherwise None.
     99         """
    100         if module_str not in self.loaded:

/usr/lib/python2.7/dist-packages/IPython/core/extensions.pyc in _call_load_ipython_extension(self=<IPython.core.extensions.ExtensionManager object>, mod=<module 'sage' from '/usr/lib/python2.7/dist-packages/sage/__init__.pyc'>)
    117         """
    118         from IPython.utils.syspathcontext import prepended_to_syspath
    119 
    120         if (module_str in self.loaded) and (module_str in sys.modules):
    121             self.unload_extension(module_str)
    122             mod = sys.modules[module_str]
    123             with prepended_to_syspath(self.ipython_extension_dir):
    124                 reload(mod)
    125             if self._call_load_ipython_extension(mod):
    126                 self.loaded.add(module_str)
    127         else:
    128             self.load_extension(module_str)
    129 
    130     def _call_load_ipython_extension(self, mod):
    131         if hasattr(mod, 'load_ipython_extension'):
--> 132             mod.load_ipython_extension(self.shell)
        mod.load_ipython_extension = <function load_ipython_extension at 0x7ff53ed02e50>
        self.shell = <sage.repl.interpreter.SageTerminalInteractiveShell object at 0x7ff53d8ab650>
    133             return True
    134 
    135     def _call_unload_ipython_extension(self, mod):
    136         if hasattr(mod, 'unload_ipython_extension'):
    137             mod.unload_ipython_extension(self.shell)
    138             return True
    139 
    140     def install_extension(self, url, filename=None):
    141         """Download and install an IPython extension. 
    142 
    143         If filename is given, the file will be so named (inside the extension
    144         directory). Otherwise, the name from the URL will be used. The file must
    145         have a .py or .zip extension; otherwise, a ValueError will be raised.
    146 
    147         Returns the full path to the installed file.

/usr/lib/python2.7/dist-packages/sage/__init__.pyc in load_ipython_extension(*args=(<sage.repl.interpreter.SageTerminalInteractiveShell object>,))
      1 __all__ = ['all']
      2 
      3 # Set sage.__version__ to the current version number. This is analogous
      4 # to many other Python packages.
      5 from sage.version import version as __version__
      6 
      7 # Make sure that the correct zlib library is loaded. This is needed
      8 # to prevent the system zlib to be loaded instead of the Sage one.
      9 # See https://trac.sagemath.org/ticket/23122
     10 import zlib
     11 
     12 # IPython calls this when starting up
     13 def load_ipython_extension(*args):
     14     import sage.repl.ipython_extension
---> 15     sage.repl.ipython_extension.load_ipython_extension(*args)
        sage.repl.ipython_extension.load_ipython_extension = <function load_ipython_extension at 0x7ff53cc395d0>
        args = (<sage.repl.interpreter.SageTerminalInteractiveShell object at 0x7ff53d8ab650>,)
     16 
     17 
     18 # Monkey-patch inspect.isfunction() to support Cython functions.
     19 def isfunction(obj):
     20     """
     21     Check whether something is a function.
     22 
     23     We assume that anything which has a genuine ``__code__``
     24     attribute (not using ``__getattr__`` overrides) is a function.
     25     This is meant to support Cython functions.
     26 
     27     EXAMPLES::
     28 
     29         sage: from inspect import isfunction
     30         sage: def f(): pass
     31         sage: isfunction(f)

/usr/lib/python2.7/dist-packages/sage/repl/ipython_extension.pyc in wrapper(*args=(<sage.repl.interpreter.SageTerminalInteractiveShell object>,), **kwargs={})
    547         ....:     if work:
    548         ....:         return 'foo worked'
    549         ....:     raise RuntimeError("foo didn't work")
    550         sage: foo(False)
    551         Traceback (most recent call last):
    552         ...
    553         RuntimeError: foo didn't work
    554         sage: foo(True)
    555         'foo worked'
    556         sage: foo(False)
    557         sage: foo(True)
    558     """
    559     @wraps(func)
    560     def wrapper(*args, **kwargs):
    561         if not wrapper.has_run:
--> 562             result = func(*args, **kwargs)
        result = undefined
        global func = undefined
        args = (<sage.repl.interpreter.SageTerminalInteractiveShell object at 0x7ff53d8ab650>,)
        kwargs = {}
    563             wrapper.has_run = True
    564             return result
    565     wrapper.has_run = False
    566     return wrapper
    567 
    568 
    569 @run_once
    570 def load_ipython_extension(ip):
    571     """
    572     Load the extension in IPython.
    573     """
    574     # this modifies ip
    575     SageCustomizations(shell=ip)

/usr/lib/python2.7/dist-packages/sage/repl/ipython_extension.pyc in load_ipython_extension(ip=<sage.repl.interpreter.SageTerminalInteractiveShell object>)
    560     def wrapper(*args, **kwargs):
    561         if not wrapper.has_run:
    562             result = func(*args, **kwargs)
    563             wrapper.has_run = True
    564             return result
    565     wrapper.has_run = False
    566     return wrapper
    567 
    568 
    569 @run_once
    570 def load_ipython_extension(ip):
    571     """
    572     Load the extension in IPython.
    573     """
    574     # this modifies ip
--> 575     SageCustomizations(shell=ip)
        global SageCustomizations = <class 'sage.repl.ipython_extension.SageCustomizations'>
        global shell = undefined
        ip = <sage.repl.interpreter.SageTerminalInteractiveShell object at 0x7ff53d8ab650>

/usr/lib/python2.7/dist-packages/sage/repl/ipython_extension.pyc in __init__(self=<sage.repl.ipython_extension.SageCustomizations object>, shell=<sage.repl.interpreter.SageTerminalInteractiveShell object>)
    418     def __init__(self, shell=None):
    419         """
    420         Initialize the Sage plugin.
    421         """
    422         self.shell = shell
    423 
    424         self.auto_magics = SageMagics(shell)
    425         self.shell.register_magics(self.auto_magics)
    426 
    427         import sage.misc.edit_module as edit_module
    428         self.shell.set_hook('editor', edit_module.edit_devel)
    429 
    430         self.init_inspector()
    431         self.init_line_transforms()
    432 
--> 433         import sage.all # until sage's import hell is fixed
        sage.all = undefined
    434 
    435         self.shell.verbose_quit = True
    436         self.set_quit_hook()
    437 
    438         self.register_interface_magics()
    439 
    440         if SAGE_IMPORTALL == 'yes':
    441             self.init_environment()
    442 
    443     def register_interface_magics(self):
    444         """
    445         Register magics for each of the Sage interfaces
    446         """
    447         from sage.repl.interface_magic import InterfaceMagic
    448         InterfaceMagic.register_all(self.shell)

/usr/lib/python2.7/dist-packages/sage/all.py in <module>()
     68 import math
     69 
     70 from sage.env import SAGE_ROOT, SAGE_SRC, SAGE_DOC_SRC, SAGE_LOCAL, DOT_SAGE, SAGE_ENV
     71 
     72 
     73 ###################################################################
     74 
     75 # This import also sets up the interrupt handler
     76 from cysignals.signals import (AlarmInterrupt, SignalError,
     77         sig_on_reset as sig_on_count)
     78 
     79 from time                import sleep
     80 from functools import reduce  # in order to keep reduce in python3
     81 
     82 import sage.misc.lazy_import
---> 83 from sage.misc.all       import *         # takes a while
        global sage.misc.all = undefined
     84 from sage.typeset.all    import *
     85 from sage.repl.all       import *
     86 
     87 from sage.misc.sh import sh
     88 
     89 from sage.libs.all       import *
     90 from sage.data_structures.all import *
     91 from sage.doctest.all    import *
     92 
     93 from sage.structure.all  import *
     94 from sage.rings.all      import *
     95 from sage.arith.all      import *
     96 from sage.matrix.all     import *
     97 
     98 from sage.symbolic.all   import *

/usr/lib/python2.7/dist-packages/sage/misc/all.py in <module>()
     69 
     70 from .defaults import (set_default_variable_name,
     71                         series_precision, set_series_precision)
     72 
     73 from .sage_eval import sage_eval, sageobj
     74 
     75 from .sage_input import sage_input
     76 
     77 lazy_import("sage.misc.cython", ["cython_lambda", "cython_create_local_so"])
     78 lazy_import("sage.misc.cython", "cython_compile", "cython")
     79 
     80 from .persist import save, load, dumps, loads, db, db_save
     81 
     82 from .func_persist import func_persist
     83 
---> 84 from .functional import (additive_order,
        global functional = undefined
        global additive_order = undefined
        global base_ring = undefined
        global base_field = undefined
        global basis = undefined
        global category = undefined
        global charpoly = undefined
        global characteristic_polynomial = undefined
        global coerce = undefined
        global cyclotomic_polynomial = undefined
        global decomposition = undefined
        global denominator = undefined
        global det = undefined
        global dimension = undefined
        global dim = undefined
        global discriminant = undefined
        global disc = undefined
        global eta = undefined
        global fcp = undefined
        global gen = undefined
        global gens = undefined
        global hecke_operator = undefined
        global image = undefined
        global integral = undefined
        global integrate = undefined
        global integral_closure = undefined
        global interval = undefined
        global xinterval = undefined
        global is_commutative = undefined
        global is_even = undefined
        global is_integrally_closed = undefined
        global is_field = undefined
        global is_odd = undefined
        global kernel = undefined
        global krull_dimension = undefined
        global lift = undefined
        global log = undefined
        global log_b = undefined
        global minimal_polynomial = undefined
        global minpoly = undefined
        global multiplicative_order = undefined
        global ngens = undefined
        global norm = undefined
        global numerator = undefined
        global numerical_approx = undefined
        global n = undefined
        global N = undefined
        global objgens = undefined
        global objgen = undefined
        global order = undefined
        global rank = undefined
        global regulator = undefined
        global round = undefined
        global quotient = undefined
        global quo = undefined
        global isqrt = undefined
        global squarefree_part = undefined
        global symbolic_sum = undefined
        global sum = undefined
        global symbolic_prod = undefined
        global product = undefined
        global transpose = undefined
     85                         base_ring,
     86                         base_field,
     87                         basis,
     88                         category,
     89                         charpoly,
     90                         characteristic_polynomial,
     91                         coerce,
     92                         cyclotomic_polynomial,
     93                         decomposition,
     94                         denominator,
     95                         det,
     96                         dimension,
     97                         dim,
     98                         discriminant,
     99                         disc,

/usr/lib/python2.7/dist-packages/sage/misc/functional.py in <module>()
     12 - David Joyner (2005-12-20): More Examples
     13 """
     14 #*****************************************************************************
     15 #       Copyright (C) 2004 William Stein <wstein@gmail.com>
     16 #
     17 # This program is free software: you can redistribute it and/or modify
     18 # it under the terms of the GNU General Public License as published by
     19 # the Free Software Foundation, either version 2 of the License, or
     20 # (at your option) any later version.
     21 #                  http://www.gnu.org/licenses/
     22 #*****************************************************************************
     23 from __future__ import absolute_import
     24 from six.moves import range, builtins
     25 from six import integer_types
     26 
---> 27 from sage.rings.complex_double import CDF
        global sage.rings.complex_double = undefined
        global CDF = undefined
     28 from sage.rings.real_double import RDF, RealDoubleElement
     29 from sage.rings.integer_ring import ZZ
     30 from sage.rings.integer import Integer
     31 from sage.misc.superseded import deprecation
     32 
     33 ##############################################################################
     34 # There are many functions on elements of a ring, which mathematicians
     35 # usually write f(x), e.g., it is weird to write x.log() and natural
     36 # to write log(x).  The functions below allow for the more familiar syntax.
     37 ##############################################################################
     38 
     39 
     40 def additive_order(x):
     41     """
     42     Return the additive order of ``x``.

/usr/lib/python2.7/dist-packages/sage/rings/integer.pxd in init sage.rings.complex_double (build/cythonized/sage/rings/complex_double.c:22703)()
      1 from sage.libs.gmp.types cimport __mpz_struct, mpz_t, mpz_ptr
      2 from sage.libs.ntl.types cimport ZZ_c
      3 
      4 from sage.structure.element cimport EuclideanDomainElement, RingElement
      5 from sage.categories.morphism cimport Morphism
      6 
----> 7 cdef class Integer(EuclideanDomainElement):
        global cdef = undefined
        global Integer = undefined
        global EuclideanDomainElement = undefined
      8     # This is really of type mpz_t, but we don't use the mpz_t typedef
      9     # to work around Cython bug
     10     # https://github.com/cython/cython/issues/1984
     11     cdef __mpz_struct value[1]
     12 
     13     cdef int _to_ZZ(self, ZZ_c *z) except -1
     14     cdef void set_from_mpz(self, mpz_t value)
     15     cdef hash_c(self)
     16 
     17     cpdef __pari__(self)
     18 
     19     cpdef _shift_helper(Integer self, y, int sign)
     20     cpdef _add_(self, other)
     21     cpdef _mul_(self, other)
     22     cpdef _pow_(self, other)
     23     cdef _and(Integer self, Integer other)
     24     cdef _or(Integer self, Integer other)
     25     cdef _xor(Integer self, Integer other)
     26 
     27     cpdef size_t _exact_log_log2_iter(self,Integer m)
     28     cpdef size_t _exact_log_mpfi_log(self,m)
     29     cpdef RingElement _valuation(Integer self, Integer p)
     30     cdef object _val_unit(Integer self, Integer p)
     31     cdef Integer _divide_knowing_divisible_by(Integer self, Integer right)

/usr/lib/python2.7/dist-packages/sage/rings/rational.pxd in init sage.rings.integer (build/cythonized/sage/rings/integer.c:51384)()
      1 from sage.libs.gmp.types cimport mpq_t
      2 
      3 cimport sage.structure.element
      4 cimport sage.rings.integer as integer
      5 
      6 cpdef rational_power_parts(a, Rational b, factor_limit=?)
      7 
----> 8 cdef class Rational(sage.structure.element.FieldElement):
        global cdef = undefined
        global Rational = undefined
        global sage.structure.element.FieldElement = undefined
      9     cdef mpq_t value
     10 
     11     cpdef _add_(self, other)
     12     cpdef _mul_(self, other)
     13     cpdef _pow_(self, other)
     14     cdef __set_value(self, x, unsigned int base)
     15     cdef void set_from_mpq(Rational self, mpq_t value)
     16     cdef _lshift(self, long int exp)
     17     cdef _rshift(self, long int exp)
     18 
     19     cdef _val_unit(self, integer.Integer p)

/usr/lib/python2.7/dist-packages/sage/rings/fast_arith.pxd in init sage.rings.rational (build/cythonized/sage/rings/rational.c:38489)()
      1 cpdef prime_range(start, stop=*, algorithm=*, bint py_ints=*)
      2 
----> 3 cdef class arith_int:
        global cdef = undefined
        global arith_int = undefined
      4     cdef int abs_int(self, int x) except -1
      5     cdef int sign_int(self, int n) except -2
      6     cdef int c_gcd_int(self, int a, int b) except -1
      7     cdef int c_xgcd_int(self, int a, int b, int* ss, int* tt) except -1
      8     cdef int c_inverse_mod_int(self, int a, int m) except -1
      9     cdef int c_rational_recon_int(self, int a, int m, int* n, int* d) except -1
     10 
     11 cdef class arith_llong:
     12     cdef long long abs_longlong(self, long long x) except -1
     13     cdef long long sign_longlong(self, long long n) except -2
     14     cdef long long c_gcd_longlong(self, long long a, long long b) except -1
     15     cdef long long c_xgcd_longlong(self, long long a, long long b,
     16                                    long long *ss,
     17                                    long long *tt) except -1
     18     cdef long long c_inverse_mod_longlong(self, long long a, long long m) except -1
     19     cdef long long c_rational_recon_longlong(self, long long a, long long m,
     20                                              long long *n, long long *d) except -1

gen.pxd in init sage.rings.fast_arith (build/cythonized/sage/rings/fast_arith.c:7917)()

AttributeError: 'module' object has no attribute 'Gen_auto'

***************************************************************************

History of session input:
*** Last line of input (may not be in above history):