Skip to content

Series[Period] and Timestamp binop causes segfault #17983

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

Closed
TomAugspurger opened this issue Oct 25, 2017 · 2 comments · Fixed by #18524
Closed

Series[Period] and Timestamp binop causes segfault #17983

TomAugspurger opened this issue Oct 25, 2017 · 2 comments · Fixed by #18524
Labels
Datetime Datetime data dtype Period Period data type
Milestone

Comments

@TomAugspurger
Copy link
Contributor

No time to look atm:

In [1]: import pandas as pd

In [2]: pd.Timestamp('2017') + pd.Series([pd.Period('2017', freq='M')])
Fatal Python error: Cannot recover from stack overflow.

Thread 0x00007000053d1000 (most recent call first):
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 295 in wait
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 551 in wait
  File "/Users/taugspurger/Envs/pandas-dev/lib/python3.6/site-packages/IPython/core/history.py", line 829 in run
  File "/Users/taugspurger/Envs/pandas-dev/lib/python3.6/site-packages/IPython/core/history.py", line 58 in needs_sqlite
  File "<decorator-gen-24>", line 2 in run
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 916 in _bootstrap_inner
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 884 in _bootstrap

Current thread 0x00007fff943f83c0 (most recent call first):
  File "/Users/taugspurger/Envs/pandas-dev/lib/python3.6/site-packages/pandas/pandas/core/ops.py", line 78 in <lambda>
  File "/Users/taugspurger/Envs/pandas-dev/lib/python3.6/site-packages/pandas/pandas/core/ops.py", line 713 in <lambda>
  File "/Users/taugspurger/Envs/pandas-dev/lib/python3.6/site-packages/pandas/pandas/core/ops.py", line 713 in safe_na_op
  File "/Users/taugspurger/Envs/pandas-dev/lib/python3.6/site-packages/pandas/pandas/core/ops.py", line 742 in wrapper
  File "<ipython-input-2-5cbafe935254>", line 1 in <module>
  File "/Users/taugspurger/Envs/pandas-dev/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2862 in run_code
  File "/Users/taugspurger/Envs/pandas-dev/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2808 in run_ast_nodes
  File "/Users/taugspurger/Envs/pandas-dev/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2698 in run_cell
  File "/Users/taugspurger/Envs/pandas-dev/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py", line 471 in interact
  File "/Users/taugspurger/Envs/pandas-dev/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py", line 480 in mainloop
  File "/Users/taugspurger/Envs/pandas-dev/lib/python3.6/site-packages/IPython/terminal/ipapp.py", line 356 in start
  File "/Users/taugspurger/Envs/pandas-dev/lib/python3.6/site-packages/traitlets/config/application.py", line 658 in launch_instance
  File "/Users/taugspurger/Envs/pandas-dev/lib/python3.6/site-packages/IPython/__init__.py", line 125 in start_ipython
  File "/Users/taugspurger/.virtualenvs/pandas-dev/bin/ipython", line 11 in <module>

The other way hits a maximum recursion error:

In [1]: import pandas as pd

In [2]: pd.Series([pd.Period('2017', freq='M')]) + pd.Timestamp('2017')


---------------------------------------------------------------------------
RecursionError                            Traceback (most recent call last)
~/Envs/pandas-dev/lib/python3.6/site-packages/pandas/pandas/core/ops.py in safe_na_op(lvalues, rvalues)
    698             with np.errstate(all='ignore'):
--> 699                 return na_op(lvalues, rvalues)
    700         except Exception:

~/Envs/pandas-dev/lib/python3.6/site-packages/pandas/pandas/core/ops.py in na_op(x, y)
    674         try:
--> 675             result = expressions.evaluate(op, str_rep, x, y, **eval_kwargs)
    676         except TypeError:

~/Envs/pandas-dev/lib/python3.6/site-packages/pandas/pandas/core/computation/expressions.py in evaluate(op, op_str, a, b, use_numexpr, **eval_kwargs)
    203     if use_numexpr:
--> 204         return _evaluate(op, op_str, a, b, **eval_kwargs)
    205     return _evaluate_standard(op, op_str, a, b)

~/Envs/pandas-dev/lib/python3.6/site-packages/pandas/pandas/core/computation/expressions.py in _evaluate_numexpr(op, op_str, a, b, truediv, reversed, **eval_kwargs)
    118     if result is None:
--> 119         result = _evaluate_standard(op, op_str, a, b)
    120

~/Envs/pandas-dev/lib/python3.6/site-packages/pandas/pandas/core/computation/expressions.py in _evaluate_standard(op, op_str, a, b, **eval_kwargs)
     63     with np.errstate(all='ignore'):
---> 64         return op(a, b)
     65

~/Envs/pandas-dev/lib/python3.6/site-packages/pandas/pandas/_libs/tslib.pyx in pandas._libs.tslib.Timestamp.__radd__()

~/Envs/pandas-dev/lib/python3.6/site-packages/pandas/pandas/_libs/period.pyx in pandas._libs.period._Period.__add__()

... last 2 frames repeated, from the frame below ...

~/Envs/pandas-dev/lib/python3.6/site-packages/pandas/pandas/_libs/tslib.pyx in pandas._libs.tslib.Timestamp.__radd__()

RecursionError: maximum recursion depth exceeded while calling a Python object

During handling of the above exception, another exception occurred:

RecursionError                            Traceback (most recent call last)
<ipython-input-2-18743c02baa6> in <module>()
----> 1 pd.Series([pd.Period('2017', freq='M')]) + pd.Timestamp('2017')

~/Envs/pandas-dev/lib/python3.6/site-packages/pandas/pandas/core/ops.py in wrapper(left, right, name, na_op)
    736                 lvalues = lvalues.values
    737
--> 738         result = wrap_results(safe_na_op(lvalues, rvalues))
    739         return construct_result(
    740             left,

~/Envs/pandas-dev/lib/python3.6/site-packages/pandas/pandas/core/ops.py in safe_na_op(lvalues, rvalues)
    707                 if is_object_dtype(lvalues):
    708                     return libalgos.arrmap_object(lvalues,
--> 709                                                   lambda x: op(x, rvalues))
    710             raise
    711

~/Envs/pandas-dev/lib/python3.6/site-packages/pandas/pandas/_libs/algos_common_helper.pxi in pandas._libs.algos.arrmap_object()

~/Envs/pandas-dev/lib/python3.6/site-packages/pandas/pandas/core/ops.py in <lambda>(x)
    707                 if is_object_dtype(lvalues):
    708                     return libalgos.arrmap_object(lvalues,
--> 709                                                   lambda x: op(x, rvalues))
    710             raise
    711

~/Envs/pandas-dev/lib/python3.6/site-packages/pandas/pandas/_libs/tslib.pyx in pandas._libs.tslib.Timestamp.__radd__()

~/Envs/pandas-dev/lib/python3.6/site-packages/pandas/pandas/_libs/period.pyx in pandas._libs.period._Period.__add__()

... last 2 frames repeated, from the frame below ...

~/Envs/pandas-dev/lib/python3.6/site-packages/pandas/pandas/_libs/tslib.pyx in pandas._libs.tslib.Timestamp.__radd__()

RecursionError: maximum recursion depth exceeded while calling a Python object
@TomAugspurger TomAugspurger added this to the Next Major Release milestone Oct 25, 2017
@TomAugspurger TomAugspurger added Period Period data type Datetime Datetime data dtype Difficulty Advanced labels Oct 25, 2017
@jbrockmendel
Copy link
Member

FWIW the segfault appears to be specific to IPython. In the standard interpreter I just get the RecursionError in both py2+py3. Should be an easy patch; should I hold off until after the next release?

@TomAugspurger
Copy link
Contributor Author

No rush, I don't think this is a major issue. I think we're doing the final release tomorrow or Friday.

@jreback jreback modified the milestones: Next Major Release, 0.22.0 Nov 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Period Period data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants