-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
Define Py_VA_COPY macro as a cross-platform replacement for gcc __va_copy #46695
Comments
In many files, the following code is present (with slight variations,
but the important part is there) :
static PyObject *
objargs_mktuple(va_list va)
{
int i, n = 0;
va_list countva;
PyObject *result, *tmp;
#ifdef VA_LIST_IS_ARRAY
memcpy(countva, va, sizeof(va_list));
#else
#ifdef __va_copy
__va_copy(countva, va);
#else
countva = va;
#endif
#endif ... memcpy() is accessing va_list before it is initialized. Before the first access to a va_list type variable, and after the last Such behaviour should be corrected in the following files :
|
Can you provide a patch for 2.6 against the latest svn checkout of the |
This is not a bug. All the reported functions expect va_list argument PyObject *
PyObject_CallFunctionObjArgs(PyObject *callable, ...)
{
PyObject *args, *tmp;
va_list vargs;
/* count the args */
va_start(vargs, callable);
args = objargs_mktuple(vargs);
va_end(vargs);
if (args == NULL)
return NULL;
tmp = PyObject_Call(callable, args, NULL);
Py_DECREF(args);
return tmp;
} This may need to be clarified in the docs. For example, PyString_FromFormatV does not mention that vargs needs to be I suggest to close this issue as invalid. |
On the second thought the macro dance highlighted by OP belongs to |
Looks like a good idea to me |
This is what I meant. The initialization should be done by calling Alexander Belopolsky wrote:
|
Actually, this thing is more complex to solve than I thought. The problem is that at least objargs_mktuple(), line 2649 of |
What's the status of this? |
Rolland, The va_list is initialized by the function that calls objargs_mktuple. Not a bug, but +1 on Alexander's patch to consolidate all the #ifdef's |
Reducing the priority and updating the target releases, since from the |
Updated the patch. In a year one more copy of va_copy macro dance have cropped in. Any reason this is still languishing? |
Rolland, Please don't revert the title. The consensus is that there is no uninitialized access to va_list. |
Looks like a good idea. Don't other compilers have __va_copy equivalents? |
I updated the patch for 3.x. I agree that using va_copy where available makes sense, but let's leave this type of improvements for the future. |
Committed in r83949. |
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: