Skip to content

BUG: Wrong results and SegFaults when indexing with uint arrays #37218

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
2 of 3 tasks
HagaiHargil opened this issue Oct 18, 2020 · 0 comments · Fixed by #37495
Closed
2 of 3 tasks

BUG: Wrong results and SegFaults when indexing with uint arrays #37218

HagaiHargil opened this issue Oct 18, 2020 · 0 comments · Fixed by #37495
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@HagaiHargil
Copy link
Contributor

HagaiHargil commented Oct 18, 2020

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

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

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Code Sample, a copy-pastable example

import pandas as pd
import numpy as np

ser = pd.Series([1, 2, 3])
arr8 = np.array([4], dtype=np.uint8)
arr16 = np.array([4], dtype=np.uint16)
arr32 = np.array([4], dtype=np.uint32)
arr64 = np.array([4], dtype=np.uint64)

print(ser[arr8])  # prints random number, probably out-of-bounds memory address
print(ser[arr16])  # prints random number, probably out-of-bounds memory address
print(ser[arr32])  # segfault
print(ser[arr64])  # correctly returns a KeyError

Problem description

Indexing into a Series without .iloc or .loc using an unsigned integer that points outside of the Series sometimes results in pandas returning some bogus value, and sometimes causes a segfault. I wasn't able to reproduce this behavior with signed integer arrays.

Expected Output

I assume that these queries should return a KeyError.

Output of pd.show_versions()

I confirmed the bug with the following two versions:

INSTALLED VERSIONS

commit : None
python : 3.7.3.final.0
python-bits : 64
OS : Linux
OS-release : 4.19.147-1-MANJARO
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : en_IL.UTF-8
LOCALE : en_IL.UTF-8

pandas : 1.0.3
numpy : 1.17.1
pytz : 2019.2
dateutil : 2.8.0
pip : 19.2.3
setuptools : 41.2.0
Cython : 0.29.19
pytest : 5.1.2
hypothesis : None
sphinx : 2.4.4
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.5.0
html5lib : None
pymysql : 0.9.3
psycopg2 : None
jinja2 : 2.10.3
IPython : 7.8.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.5.0
matplotlib : 3.1.1
numexpr : 2.7.1
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 5.1.2
pyxlsb : None
s3fs : None
scipy : 1.3.1
sqlalchemy : None
tables : 3.6.1
tabulate : None
xarray : 0.15.1
xlrd : 1.2.0
xlwt : None
xlsxwriter : None
numba : 0.45.1

INSTALLED VERSIONS

commit : None
python : 3.7.3.final.0
python-bits : 64
OS : Linux
OS-release : 4.19.147-1-MANJARO
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : en_IL.UTF-8
LOCALE : en_IL.UTF-8

pandas : 1.0.3
numpy : 1.17.1
pytz : 2019.2
dateutil : 2.8.0
pip : 19.2.3
setuptools : 41.2.0
Cython : 0.29.19
pytest : 5.1.2
hypothesis : None
sphinx : 2.4.4
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.5.0
html5lib : None
pymysql : 0.9.3
psycopg2 : None
jinja2 : 2.10.3
IPython : 7.8.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.5.0
matplotlib : 3.1.1
numexpr : 2.7.1
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 5.1.2
pyxlsb : None
s3fs : None
scipy : 1.3.1
sqlalchemy : None
tables : 3.6.1
tabulate : None
xarray : 0.15.1
xlrd : 1.2.0
xlwt : None
xlsxwriter : None
numba : 0.45.1

@HagaiHargil HagaiHargil added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 18, 2020
@jreback jreback added this to the 1.2 milestone Oct 30, 2020
@jreback jreback added Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves and removed Dtype Conversions Unexpected or buggy dtype conversions Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants