Skip to content

Handle FLINT exceptions gracefully #17629

@rwst

Description

@rwst

Sage crashes with

sage: (x^2222222222+1).polynomial(QQ)
...
#2  0x00007f46536d606d in sigdie()
#3  0x00007f46536d575a in sage_signal_handler()
#4  0x00007f46596f03e0 in __restore_rt()
#5  0x00007f46590e70a0 in raise()
#6  0x00007f465865c3a0 in abort()
#7  0x00007f4645da4b40 in flint_memory_error()
#8  0x00007f4645daa400 in flint_calloc()
#9  0x00007f4645e00150 in fmpq_poly_realloc()
#10 0x00007f4645e058a0 in fmpq_poly_fit_length()
#11 0x00007f4645dff850 in fmpq_poly_set_coeff_si()
#12 0x00007f463c1b6f30 in __pyx_pf_4sage_5rings_10polynomial_25polynomial_rational_flint_25Polynomial_rational_flint_58__pow__() at /home/ralf/sage/src/build/cythonized/sage/rings/polynomial/polynomial_rational_flint.cpp:10287
  10282     *             if self._is_gen:
  10283     *                 fmpq_poly_set_coeff_si(res.__poly, n, 1)             # <<<<<<<<<<<<<<
  10284     *             else:
  10285     *                 sig_on()
  10286     */
> 10287          fmpq_poly_set_coeff_si(__pyx_v_res->__pyx___poly, __pyx_v_n, 1);
  10288          goto __pyx_L16;
  10289        }
  10290        /*else*/ {
  10291    
#13 0x00007f465933e270 in ternary_op()
#14 0x00007f4659340520 in PyNumber_Power()
#15 0x00007f46593e62b0 in arithmetic() at /home/ralf/sage/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py:1110
  1105            if not any(repr(v) in self.varnames for v in ex.variables()):
  1106                return self.base_ring(ex)
  1107            elif operator == _operator.pow:
  1108                from sage.rings.all import Integer
  1109                base, exp = ex.operands()
> 1110                return self(base)**Integer(exp)
  1111            else:

Depends on #17668

Component: c_lib

Keywords: flint_memory_error

Author: Jeroen Demeyer

Branch/Commit: 4835d4b

Reviewer: Ralf Stephan

Issue created by migration from https://trac.sagemath.org/ticket/17629

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions