-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
[easy C] array.array.index() method downcasts Py_ssize_t to long #85257
Comments
Here's the verbose stack trace of the failing test: ====================================================================== Traceback (most recent call last):
File "L:\GIT\cpython\lib\test\support\__init__.py", line 837, in wrapper
return f(self, maxsize)
File "L:\GIT\cpython\lib\test\test_array.py", line 1460, in test_index
self.assertEqual(example.index(11), size+3)
AssertionError: -2147483645 != 2147483651 |
This looks like an overflow failure in a bigmem test (though the given limit 24Gb should accommodate that?). Do bigmem tests work on Windows? William, you've made some sort of modifications to the versioned files, what are those? |
The only modification I made was to "rt.bat" to have the value of '-u' work properly. |
It's Python 3.10 on Windows built in 64-bit with Visual Studio. Extract of test_output.log: L:\GIT\cpython\PCbuild>"L:\GIT\cpython\PCbuild\amd64\python_d.exe" -u -Wd -E -bb -m test -u all,-curses -v -M 24Gb --header == CPython 3.10.0a0 (heads/master-dirty:c96d00e88e, Jun 22 2020, 19:15:48) [MSC v.1926 64 bit (AMD64)] Traceback (most recent call last):
File "L:\GIT\cpython\lib\test\support\__init__.py", line 837, in wrapper
return f(self, maxsize)
File "L:\GIT\cpython\lib\test\test_array.py", line 1460, in test_index
self.assertEqual(example.index(11), size+3)
AssertionError: -2147483645 != 2147483651 |
That's a bug in array_array_index() which downcasts "Py_ssize_t i" to long: static PyObject *
array_array_index(arrayobject *self, PyObject *v)
/*[clinic end generated code: output=d48498d325602167 input=cf619898c6649d08]*/
{
Py_ssize_t i;
for (i = 0; i < Py_SIZE(self); i++) {
PyObject *selfi;
int cmp;
selfi = getarrayitem((PyObject *)self, i);
if (selfi == NULL)
return NULL;
cmp = PyObject_RichCompareBool(selfi, v, Py_EQ);
Py_DECREF(selfi);
if (cmp > 0) {
return PyLong_FromLong((long)i); // <===== HERE ===
}
else if (cmp < 0)
return NULL;
}
PyErr_SetString(PyExc_ValueError, "array.index(x): x not in array");
return NULL;
} |
Thanks William Pickard for the bug report and the fix! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: