You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
assignee=Noneclosed_at=<Date2010-08-25.23:13:27.378>created_at=<Date2010-08-25.22:44:35.116>labels= ['type-bug']
title='object.__basicsize__ is erroneously 0 on big-endian 64-bit machines (int vs Py_ssize_t)'updated_at=<Date2010-08-25.23:13:27.376>user='https://github.com/davidmalcolm'
On 64-bit bigendian machines (ppc64 and s390x), I'm seeing:
>>> printobject.__basicsize__
0
(Discovered via a segfault in Jinja2 tries to use ctypes to manipulate ob_refcnt of variables, and gets the wrong location, corrupting the objects instead; see https://bugzilla.redhat.com/show_bug.cgi?id=627347 )
struct _typeobject declares tp_basicsize and tp_itemsize as Py_ssize_t:
{
...
Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */
...
}
but type_members defines them as T_INT:
{"__basicsize__", T_INT, offsetof(PyTypeObject,tp_basicsize),READONLY},
{"__itemsize__", T_INT, offsetof(PyTypeObject, tp_itemsize), READONLY},
Hence when accessing "object.__basicsize__", PyMember_GetOne reads it as a
T_INT, which gets it as 0 (incorrect). Accessing it as Py_ssize_t reads it as
16 (correct)
(gdb) p *(Py_ssize_t*)addr
$9 = 16
(gdb) p *(int*)addr
$10 = 0
I'm attaching a patch which changes them to use T_PYSSIZE_T and adds a selftest.
davidmalcolm
changed the title
object.__basicsize__ is erroneously0
object.__basicsize__ is erroneously 0 on big-endian 64-bit machines (int vs Py_ssize_t)
Aug 25, 2010
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: