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

BUG: segfault from json.dumps in Python 3.10 #42130

Closed
fangchenli opened this issue Jun 19, 2021 · 4 comments · Fixed by #45558
Closed

BUG: segfault from json.dumps in Python 3.10 #42130

fangchenli opened this issue Jun 19, 2021 · 4 comments · Fixed by #45558
Assignees
Labels
Bug IO JSON read_json, to_json, json_normalize Python 3.10 Segfault Non-Recoverable Error
Milestone

Comments

@fangchenli
Copy link
Member

fangchenli commented Jun 19, 2021

The segfault is from pandas/tests/io/json/test_pandas::TestPandasContainer::test_tz_is_utc and pandas/tests/io/json/test_pandas::TestPandasContainer::test_tz_range_is_utc

@fangchenli
Copy link
Member Author

#42518 The segfault seems disappeared somehow.

@kleschenko
Copy link

kleschenko commented Jan 13, 2022

@fangchenli It seems like this (or related) issue is still happening in the final Python 3.10 builds. Here is a reproducible scenario using the docker image:

$ docker run -it --rm python:3.10.1-slim-buster bash
Unable to find image 'python:3.10.1-slim-buster' locally
...
root@4064d1f7d5c9:/# pip install pandas ipython
...
root@4064d1f7d5c9:/# ipython
Python 3.10.1 (main, Dec 21 2021, 09:50:13) [GCC 8.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.0.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import pandas as pd

In [2]: df = pd.read_json('{"columns":["timestamp","forecast_distance","forecast_point","prediction"],"index":[0],"data":[["200
   ...: 8-07-31T21:04:19.800000Z",100,"2008-07-31T21:04:19.700Z",9.30289263e+123]]}', orient='split', convert_dates=False, conv
   ...: ert_axes=False)

In [3]: df.to_json(orient="split", date_format="iso", index=False)
Out[3]: '{"columns":["timestamp","forecast_distance","forecast_point","prediction"],"data":[["2008-07-31T21:04:19.800000Z",100,"2008-07-31T21:04:19.700Z",9.30289263e+123]]}'

In [4]: df["forecast_point"] = pd.to_datetime(df["forecast_point"])

In [5]: df.to_json(orient="split", date_format="iso", index=False)
Segmentation fault (core dumped)
root@4064d1f7d5c9:/# 

@lithomas1 lithomas1 self-assigned this Jan 14, 2022
@jreback jreback added this to the 1.4.1 milestone Jan 22, 2022
@lithomas1
Copy link
Member

Hi @kleschenko, I think my PR fixes this.
This is what I get on my PR. Is this correct?

>>> import pandas as pd
>>> df = pd.read_json('{"columns":["timestamp","forecast_distance","forecast_point","prediction"],"index":[0],"data":[["2008-07-31T21:04:19.800000Z",100,"2008-07-31T21:04:19.700Z",9.30289263e+123]]}', orient='split', convert_dates=False, convert_axes=False)
>>> df.to_json(orient="split", date_format="iso", index=False)
'{"columns":["timestamp","forecast_distance","forecast_point","prediction"],"data":[["2008-07-31T21:04:19.800000Z",100,"2008-07-31T21:04:19.700Z",9.30289263e+123]]}'
>>> df["forecast_point"] = pd.to_datetime(df["forecast_point"])
>>> df.to_json(orient="split", date_format="iso", index=False)
'{"columns":["timestamp","forecast_distance","forecast_point","prediction"],"data":[["2008-07-31T21:04:19.800000Z",100,"2008-07-31T21:04:19.700Z",9.30289263e+123]]}'

@kleschenko
Copy link

@lithomas1 yes, it is correct. Thanks for looking into this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO JSON read_json, to_json, json_normalize Python 3.10 Segfault Non-Recoverable Error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants