Opened 7 years ago

Closed 6 years ago

#16165 closed defect (fixed)

old pari triggers segfault in Expression.roots(rings=CC)

Reported by: rws Owned by:
Priority: major Milestone: sage-6.4
Component: interfaces Keywords: pari, roots
Cc: Merged in:
Authors: Ralf Stephan Reviewers: Peter Bruin
Report Upstream: N/A Work issues:
Branch: 5ae1043 (Commits) Commit: 5ae104354f3375f1fbc7076252c0d30282a68952
Dependencies: #15767 Stopgaps:

Description

sage: f=(1+x+x^2)^3
sage: f.roots(ring=CC)
---------------------------------------------------------------------------
SignalError                               Traceback (most recent call last)
<ipython-input-2-e28890a572d2> in <module>()
----> 1 f.roots(ring=CC)

/home/ralf/sage/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.roots (sage/symbolic/expression.cpp:38111)()

/home/ralf/sage/local/lib/python2.7/site-packages/sage/rings/polynomial/polynomial_element.so in sage.rings.polynomial.polynomial_element.Polynomial.roots (sage/rings/polynomial/polynomial_element.c:36164)()

/home/ralf/sage/local/lib/python2.7/site-packages/sage/libs/pari/gen.so in sage.libs.pari.gen.gen.polroots (sage/libs/pari/gen.c:42565)()

/home/ralf/sage/local/lib/python2.7/site-packages/sage/ext/c_lib.so in sage.ext.c_lib.sig_raise_exception (sage/ext/c_lib.c:1208)()

SignalError: Segmentation fault
sage: gp_version()
((2, 5, 5), 'GP/PARI CALCULATOR Version 2.5.5 (released)')

Change History (8)

comment:1 Changed 7 years ago by rws

  • Dependencies set to #15767
  • Summary changed from segfault in Expression.roots(rings=CC) to old pari triggers segfault in Expression.roots(rings=CC)

This goes away with pari-2.7.0 (#15767), so dependency set.

sage: f=(1+x+x^2)^3
sage: f.roots(ring=CC)
[(-0.500000000000000 - 0.866025403784439*I, 3),
 (-0.500000000000000 + 0.866025403784439*I, 3)]

comment:2 Changed 7 years ago by rws

  • Branch set to u/rws/segfault_in_expression_roots_rings_cc_

comment:3 Changed 7 years ago by rws

  • Authors set to Ralf Stephan
  • Commit set to 5ae104354f3375f1fbc7076252c0d30282a68952
  • Milestone changed from sage-6.2 to sage-pending
  • Status changed from new to needs_review

New commits:

5ae104316165: add doctest

comment:4 Changed 7 years ago by pbruin

That is interesting; I can reproduce this in Sage, but it doesn't happen when trying it directly in GP:

sage -gp
...
(18:33) gp > f=(1+x+x^2)^3
%1 = x^6 + 3*x^5 + 6*x^4 + 7*x^3 + 6*x^2 + 3*x + 1
(18:33) gp > polroots(f)
%2 = [-0.50000000000000000000000000000000000000 - 0.86602540378443864676372317075293618348*I, -0.50000000000000000000000000000000000000 + 0.86602540378443864676372317075293618348*I, -0.50000000000000000000000000000000000000 - 0.86602540378443864676372317075293618348*I, -0.50000000000000000000000000000000000000 + 0.86602540378443864676372317075293618348*I, -0.50000000000000000000000000000000000000 - 0.86602540378443864676372317075293618348*I, -0.50000000000000000000000000000000000000 + 0.86602540378443864676372317075293618348*I]~

First multiplying f by 1.0 + 0.0*I makes no difference. The Sage -> PARI conversion isn't the problem either:

sage: f=(1+x+x^2)^3
sage: pari(f).polroots()
[-0.500000000000000 - 0.866025403784439*I, -0.500000000000000 + 0.866025403784439*I, -0.500000000000000 - 0.866025403784439*I, -0.500000000000000 + 0.866025403784439*I, -0.500000000000000 - 0.866025403784439*I, -0.500000000000000 + 0.866025403784439*I]~

comment:5 Changed 7 years ago by pbruin

It is reproducible in GP if one first changes the precision from 128 bits (38 digits, PARI's default) to 64 bits (19 digits), which is the precision used to handle Sage's 53-bit precision reals:

(20:43) gp > \p19
(20:43) gp > polroots(1.0*(1+x+x^2)^3)
  ***   at top-level: polroots(1.0*(1+x+x^
  ***                 ^--------------------
  *** polroots: bug in PARI/GP (Segmentation Fault), please report

This is indeed fixed in PARI/GP 2.7.0.

comment:6 Changed 7 years ago by rws

  • Priority changed from critical to major

comment:7 Changed 6 years ago by pbruin

  • Milestone changed from sage-pending to sage-6.4
  • Reviewers set to Peter Bruin
  • Status changed from needs_review to positive_review

comment:8 Changed 6 years ago by vbraun

  • Branch changed from u/rws/segfault_in_expression_roots_rings_cc_ to 5ae104354f3375f1fbc7076252c0d30282a68952
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.