This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2013年05月07日 18:29 by David.Edelsohn, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (6) | |||
|---|---|---|---|
| msg188677 - (view) | Author: David Edelsohn (David.Edelsohn) * | Date: 2013年05月07日 18:29 | |
Another endianness bug that causes a failure in test_structmembers.py. _testcapi reports "string too long" because getargs.c:PyArg_ParseTupleAndKeywords() incorrectly returns a huge value for string_len. The problem is FETCH_ARGS is passing the wrong type to va_arg. It grabs an "int" for the size arg, but that is the not the argument type on 64 bit platforms. This happens to work for little endian because the low part of the 64 bit argument overlaps correctly. Big endian is not as fortuitous. If I change "int" to "long", the testcase succeeds. diff -r a285ce18bd55 Python/getargs.c --- a/Python/getargs.c Mon May 06 18:21:10 2013 -0700 +++ b/Python/getargs.c Tue May 07 11:26:21 2013 -0700 @@ -582,9 +582,9 @@ char *msgbuf, size_t bufsize, PyObject **freelist) { /* For # codes */ -#define FETCH_SIZE int *q=NULL;Py_ssize_t *q2=NULL;\ +#define FETCH_SIZE long *q=NULL;Py_ssize_t *q2=NULL;\ if (flags & FLAG_SIZE_T) q2=va_arg(*p_va, Py_ssize_t*); \ - else q=va_arg(*p_va, int*); + else q=va_arg(*p_va, long*); #define STORE_SIZE(s) \ if (flags & FLAG_SIZE_T) \ *q2=s; \ I am not certain exactly what type it should be, but it definitely needs to be a matching 64 bit type of 64 bit platforms. I believe that this bug exists in all versions. |
|||
| msg188695 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2013年05月07日 23:57 | |
Is it 2.7-only? |
|||
| msg188696 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2013年05月08日 00:07 | |
New changeset a199ec80c679 by Antoine Pitrou in branch '2.7': Issue #17928: Fix test_structmembers on 64-bit big-endian machines. http://hg.python.org/cpython/rev/a199ec80c679 |
|||
| msg188698 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2013年05月08日 00:32 | |
Fixed. _testcapi was actually the culprit. |
|||
| msg189392 - (view) | Author: jan matejek (matejcik) * | Date: 2013年05月16日 17:55 | |
The fix causes regression on my 64bit little-endian machine. It seems that while parsing the arguments, the length value overwrites part of the string pointer. |
|||
| msg189395 - (view) | Author: jan matejek (matejcik) * | Date: 2013年05月16日 18:05 | |
hmm, but it's caused by a private patch claiming that _testcapimodule.c is PY_SSIZE_T_CLEAN. sorry for the noise. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:45 | admin | set | github: 62128 |
| 2013年05月16日 18:05:04 | matejcik | set | messages: + msg189395 |
| 2013年05月16日 17:55:31 | matejcik | set | nosy:
+ matejcik messages: + msg189392 |
| 2013年05月08日 00:32:38 | pitrou | set | status: open -> closed resolution: fixed messages: + msg188698 stage: resolved |
| 2013年05月08日 00:07:22 | python-dev | set | nosy:
+ python-dev messages: + msg188696 |
| 2013年05月07日 23:57:29 | pitrou | set | messages: + msg188695 |
| 2013年05月07日 18:29:22 | David.Edelsohn | create | |