Victor Stinner pointed out that on x86 Gentoo Installed with X 3.x buildbot, there is a compiler warning:
Python/pystate.c:1483:18: warning: cast to pointer from integer of
different size [-Wint-to-pointer-cast]
(https://buildbot.python.org/all/#/builders/103/builds/2067)
This warning reveals a bug:
static int
_long_shared(PyObject *obj, _PyCrossInterpreterData *data)
{
int64_t value = PyLong_AsLongLong(obj);
if (value == -1 && PyErr_Occurred()) {
if (PyErr_ExceptionMatches(PyExc_OverflowError)) {
PyErr_SetString(PyExc_OverflowError, "try sending as bytes");
}
return -1;
}
data->data = (void *)value;
A 64-bit value is converted to void *, which is 32-bit on 32-bit platforms.
I've implemented a PR that uses Py_ssize_t instead to match the pointer size and to preserve the ability to work with negative numbers. |