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
PowerLinux getargs.c FETCH_SIZE endianness bug #62128
Comments
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. |
Is it 2.7-only? |
New changeset a199ec80c679 by Antoine Pitrou in branch '2.7': |
Fixed. _testcapi was actually the culprit. |
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. |
hmm, but it's caused by a private patch claiming that _testcapimodule.c is PY_SSIZE_T_CLEAN. sorry for the noise. |
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: