Skip to content

BUG: random crash / hang when calculating rolling sum #59121

Closed
@e271p314

Description

@e271p314

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import numpy as np
import pandas as pd

def func():
    cols = ['A', 'B', 'C']
    df = pd.DataFrame({c: np.random.randn(500000) for c in cols})
    sec_lst = [60 * m for m in range(1, 10)]
    sec_lst += [60 * m for m in range(10, 30, 5)]
    sec_lst += [60 * m for m in range(30, 60, 10)]
    sec_lst += [60 * m for m in range(60, 120, 15)]
    sec_lst += [60 * m for m in range(120, 180, 20)]
    sec_lst += [60 * m for m in range(180, 600, 30)]
    sec_lst += [3600 * h for h in range(10, 24)]
    df_sum_dict = {}
    for sec in sec_lst:
        for c in cols:
            try:
                df_sum_dict[f'{c}{sec}'] = df[c].rolling(sec).sum()
            except Exception as e:
                print(f"Error processing column {c} with window {sec}: {e}")
                continue

func()

Issue Description

running with this loop results in the following output (Terminated is the output when I kill it because the script hangs, should run few seconds at most)

$ for i in $(seq 1 100); do python test.py $i; if [ $? -ne 0 ]; then echo $i; fi; done
Segmentation fault (core dumped)
6
Terminated
24
Terminated
41
Segmentation fault (core dumped)
42
Segmentation fault (core dumped)
43
Terminated
44
Segmentation fault (core dumped)
45
Terminated
64
Terminated
65
Segmentation fault (core dumped)
74
Segmentation fault (core dumped)
95

Expected Behavior

it should not crash or hang

Installed Versions

INSTALLED VERSIONS

commit : d9cdd2e
python : 3.12.3.final.0
python-bits : 64
OS : Linux
OS-release : 6.8.0-35-generic
Version : #35-Ubuntu SMP PREEMPT_DYNAMIC Mon May 20 15:51:52 UTC 2024
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.2.2
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.9.0.post0
setuptools : 70.0.0
pip : 24.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.4
IPython : 8.25.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : 1.4.0
dataframe-api-compat : None
fastparquet : None
fsspec : 2024.6.0
gcsfs : 2024.6.0
matplotlib : 3.9.0
numba : 0.59.1
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 16.1.0
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.13.1
sqlalchemy : 2.0.30
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2024.1
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNeeds TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions