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

Python using sympy 1.3 core dumps when calling rubi_integrate #15657

Open
nasser1 opened this issue Dec 17, 2018 · 4 comments
Open

Python using sympy 1.3 core dumps when calling rubi_integrate #15657

nasser1 opened this issue Dec 17, 2018 · 4 comments

Comments

@nasser1
Copy link

nasser1 commented Dec 17, 2018

I am getting an Aborted (core dumped) from Python itself when using rubi_integrate in sympy 1.3

>which python
/opt/anaconda/bin/python
>python --version
Python 3.7.0

Here are the steps to reproduce it

>python
Python 3.7.0 (default, Jun 28 2018, 13:15:42) 
[GCC 7.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from sympy import *
>>> from sympy.integrals.rubi.rubi import rubi_integrate 
>>> d,a,x,r,a,b,c,n,e=symbols('d a x r a b c n e')
>>> rubi_integrate((d+e*x**r)**3*(a+b*ln(c*x**n))/x,x)
Fatal Python error: Cannot recover from stack overflow.

Current thread 0x00007f35940eb740 (most recent call first):
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/basic.py", line 321 in __eq__
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/expr.py", line 177 in __div__
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/decorators.py", line 132 in binary_op_wrapper
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/decorators.py", line 91 in __sympifyit_wrapper
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/numbers.py", line 697 in __div__
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/decorators.py", line 91 in __sympifyit_wrapper
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/numbers.py", line 1649 in __div__
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/decorators.py", line 91 in __sympifyit_wrapper
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/mul.py", line 1074 in _combine_inverse
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/operations.py", line 200 in _matches_commutative
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/mul.py", line 965 in matches
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/operations.py", line 205 in _matches_commutative
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/add.py", line 397 in matches
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/operations.py", line 217 in _matches_commutative
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/add.py", line 397 in matches
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/power.py", line 1308 in matches
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/operations.py", line 205 in _matches_commutative
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/mul.py", line 965 in matches
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/operations.py", line 217 in _matches_commutative
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/mul.py", line 965 in matches
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/operations.py", line 215 in _matches_commutative
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/add.py", line 397 in matches
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/operations.py", line 205 in _matches_commutative
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/add.py", line 397 in matches
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/operations.py", line 217 in _matches_commutative
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/add.py", line 397 in matches
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/core/basic.py", line 1541 in match
  File "/opt/anaconda/lib/python3.7/site-packages/sympy/integrals/rubi/utility_function.py", line 1836 in CollectReciprocals
  ...
Aborted (core dumped)
>

Running on Linux Manjaro 18

Thank you
--Nasser

@asmeurer
Copy link
Member

In SymPy master I get

>>> rubi_integrate((d+e*x**r)**3*(a+b*ln(c*x**n))/x,x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "./sympy/integrals/rubi/rubi.py", line 308, in rubi_integrate
    expr = expr.replace(sym_exp, exp)
NameError: name 'sym_exp' is not defined

Anyway, a core dump indicates a bug in Python, since we are not using any extension modules. Since it's a stack overflow, it means that even if Python had not crashed, it would have resulted in a RecursionError.

@asmeurer
Copy link
Member

Oh I forgot Rubi requires Python 3.6. So apparently there is a bug that Rubi doesn't properly indicate that 3.5 isn't supported. This is what I get on 3.6:

>>> rubi_integrate((d+e*x**r)**3*(a+b*ln(c*x**n))/x,x)
Traceback (most recent call last):
  File "./sympy/polys/polyutils.py", line 209, in _parallel_dict_from_expr_if_gens
    monom[indices[base]] = exp
KeyError: (1/x)**(1/3)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "./sympy/integrals/rubi/rubi.py", line 322, in rubi_integrate
    results = rubi.replace(Integral(expr, var), max_count = 10)
  File "/Users/aaronmeurer/anaconda3/envs/python36/lib/python3.6/site-packages/matchpy/matching/many_to_one.py", line 796, in replace
    replacement, subst = next(iter(self.matcher.match(subexpr)))
  File "/Users/aaronmeurer/anaconda3/envs/python36/lib/python3.6/site-packages/matchpy/matching/many_to_one.py", line 99, in __iter__
    for _ in self._match(self.matcher.root):
  File "/Users/aaronmeurer/anaconda3/envs/python36/lib/python3.6/site-packages/matchpy/matching/many_to_one.py", line 148, in _match
    yield from self._match_transition(transition)
  File "/Users/aaronmeurer/anaconda3/envs/python36/lib/python3.6/site-packages/matchpy/matching/many_to_one.py", line 162, in _match_transition
    yield from self._match_regular_operation(transition)
  File "/Users/aaronmeurer/anaconda3/envs/python36/lib/python3.6/site-packages/matchpy/matching/many_to_one.py", line 310, in _match_regular_operation
    for new_state in self._check_transition(transition, subject, False):
  File "/Users/aaronmeurer/anaconda3/envs/python36/lib/python3.6/site-packages/matchpy/matching/many_to_one.py", line 209, in _check_transition
    yield from self._match(transition.target)
  File "/Users/aaronmeurer/anaconda3/envs/python36/lib/python3.6/site-packages/matchpy/matching/many_to_one.py", line 148, in _match
    yield from self._match_transition(transition)
  File "/Users/aaronmeurer/anaconda3/envs/python36/lib/python3.6/site-packages/matchpy/matching/many_to_one.py", line 160, in _match_transition
    yield from self._match_commutative_operation(transition.target)
  File "/Users/aaronmeurer/anaconda3/envs/python36/lib/python3.6/site-packages/matchpy/matching/many_to_one.py", line 292, in _match_commutative_operation
    self._check_constraints(variable, restore_constraints, restore_patterns)
  File "/Users/aaronmeurer/anaconda3/envs/python36/lib/python3.6/site-packages/matchpy/matching/many_to_one.py", line 235, in _check_constraints
    if not constraint(self.substitution):
  File "/Users/aaronmeurer/anaconda3/envs/python36/lib/python3.6/site-packages/matchpy/expressions/constraints.py", line 190, in __call__
    return self.constraint(**args)
  File "./sympy/integrals/rubi/constraints.py", line 3211, in cons_f590
    return PseudoBinomialPairQ(u*x**(m/p), v, x)
  File "./sympy/integrals/rubi/utility_function.py", line 2766, in PseudoBinomialPairQ
    lst1 = PseudoBinomialParts(u, x)
  File "./sympy/integrals/rubi/utility_function.py", line 2748, in PseudoBinomialParts
    if PolynomialQ(u, x) and Greater(Expon(u, x), S(2)):
  File "./sympy/integrals/rubi/utility_function.py", line 1059, in PolynomialQ
    deg = degree(u, x.base)
  File "./sympy/polys/polytools.py", line 4458, in degree
    p, _ = poly_from_expr(f, gen)
  File "./sympy/polys/polytools.py", line 4266, in poly_from_expr
    return _poly_from_expr(expr, opt)
  File "./sympy/polys/polytools.py", line 4288, in _poly_from_expr
    rep, opt = _dict_from_expr(expr, opt)
  File "./sympy/polys/polyutils.py", line 366, in _dict_from_expr
    rep, gens = _dict_from_expr_if_gens(expr, opt)
  File "./sympy/polys/polyutils.py", line 305, in _dict_from_expr_if_gens
    (poly,), gens = _parallel_dict_from_expr_if_gens((expr,), opt)
  File "./sympy/polys/polyutils.py", line 215, in _parallel_dict_from_expr_if_gens
    "the set of generators." % factor)
sympy.polys.polyerrors.PolynomialError: (1/x)**(1/3) contains an element of the set of generators.

@RituRajSingh878
Copy link
Contributor

In SymPy master I get

>>> rubi_integrate((d+e*x**r)**3*(a+b*ln(c*x**n))/x,x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "./sympy/integrals/rubi/rubi.py", line 308, in rubi_integrate
    expr = expr.replace(sym_exp, exp)
NameError: name 'sym_exp' is not defined

Anyway, a core dump indicates a bug in Python, since we are not using any extension modules. Since it's a stack overflow, it means that even if Python had not crashed, it would have resulted in a RecursionError.

@asmeurer can you give me some suggestions to solve this issue.

@asmeurer
Copy link
Member

I think getting rubi to give a proper error in Python < 3.6 would be a good start.

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