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

Segfault when pickling array >2G size #17045

Closed
iynehz opened this issue Aug 10, 2020 · 1 comment · Fixed by #17059
Closed

Segfault when pickling array >2G size #17045

iynehz opened this issue Aug 10, 2020 · 1 comment · Fixed by #17059

Comments

@iynehz
Copy link
Contributor

iynehz commented Aug 10, 2020

See below for reproducing code. I studied it a little bit and found it caused by this line You see it converts iter->index to int which is 4 bytes

PyList_SET_ITEM(list, (int) iter->index, theobject);

btw seems this (int) conversion is used at multiple places like

theobject = PyList_GET_ITEM(list, (int) iter->index);

Reproducing code example:

To try this you probably need a machine of large memory. Mine is 64GB and I believe 32GB is not enough.

import numpy as np
x = np.empty(2**31+1, dtype='object')
x.__reduce__()

Numpy/Python version information:

1.19.1 3.8.2 (default, Jul 16 2020, 14:00:26)
[GCC 9.3.0]

@eric-wieser
Copy link
Member

I suspect this is a holdover from when PyList_GET_ITEM accepted int and not Py_ssize_t.

This looks like a very easy fix (remove the casts), want to make a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants