Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
rwst opened this issue Apr 15, 2014 · 10 comments
Closed

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

rwst opened this issue Apr 15, 2014 · 10 comments

Comments

@rwst
Copy link

rwst commented Apr 15, 2014

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)')

Depends on #15767

Component: interfaces

Keywords: pari, roots

Author: Ralf Stephan

Branch/Commit: 5ae1043

Reviewer: Peter Bruin

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

@rwst rwst added this to the sage-6.2 milestone Apr 15, 2014
@rwst
Copy link
Author

rwst commented Apr 17, 2014

Dependencies: #15767

@rwst
Copy link
Author

rwst commented Apr 17, 2014

comment:1

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)]

@rwst rwst changed the title segfault in Expression.roots(rings=CC) old pari triggers segfault in Expression.roots(rings=CC) Apr 17, 2014
@rwst
Copy link
Author

rwst commented Apr 17, 2014

@rwst
Copy link
Author

rwst commented Apr 17, 2014

New commits:

5ae104316165: add doctest

@rwst
Copy link
Author

rwst commented Apr 17, 2014

Commit: 5ae1043

@rwst
Copy link
Author

rwst commented Apr 17, 2014

Author: Ralf Stephan

@rwst rwst removed this from the sage-6.2 milestone Apr 17, 2014
@rwst rwst added the pending label Apr 17, 2014
@pjbruin
Copy link
Contributor

pjbruin commented Apr 17, 2014

comment:4

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]~

@pjbruin
Copy link
Contributor

pjbruin commented Apr 17, 2014

comment:5

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.

@pjbruin
Copy link
Contributor

pjbruin commented Aug 18, 2014

Reviewer: Peter Bruin

@vbraun
Copy link
Member

vbraun commented Aug 20, 2014

Changed branch from u/rws/segfault_in_expression_roots_rings_cc_ to 5ae1043

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants