-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-40052: Fix alignment issue in PyVectorcall_Function() #19133
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
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). Recognized GitHub usernameWe couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames: This might be simply due to a missing "GitHub Name" entry in one's b.p.o account settings. This is necessary for legal reasons before we can look at this contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
I've added my github username to my account on bugs.python.org and signed the CA. However I think it might take some time till the system gets the update. |
96a212a
to
a494155
Compare
In file included from /usr/include/python3.8/Python.h:147: In file included from /usr/include/python3.8/abstract.h:837: /usr/include/python3.8/cpython/abstract.h:91:11: error: cast from 'char *' to 'vectorcallfunc *' (aka 'struct _object *(**)(struct _object *, struct _object *const *, unsigned long, struct _object *)') increases required alignment from 1 to 8 [-Werror,-Wcast-align] ptr = (vectorcallfunc*)(((char *)callable) + offset); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. Signed-off-by: Andreas Schneider <[email protected]>
a494155
to
e6f4de5
Compare
ptr = (vectorcallfunc *)(((char *)callable) + offset); | ||
return *ptr; | ||
vc.data = (char *)callable + offset; | ||
return *vc.ptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is better. The correct, idiomatic solution is something like:
vectorcallfunc *ptr;
memcpy(ptr, (char *) callable + offset, sizeof(ptr));
return *ptr;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(also, note that any decent compiler will optimize the memcpy call away)
@@ -215,7 +219,8 @@ PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *kwargs) | |||
Py_TYPE(callable)->tp_name); | |||
return NULL; | |||
} | |||
vectorcallfunc func = *(vectorcallfunc *)(((char *)callable) + offset); | |||
vc.data = (char *)callable + offset; | |||
vectorcallfunc func = *vc.ptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase And if you don't make the requested changes, you will be poked with soft cushions! |
In my experience, memcpy() is good solution for such problem. |
I've made a PR with the suggested |
Closing in favour of #23999. |
https://bugs.python.org/issue40052