FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-40052: Fix alignment issue in PyVectorcall_Function() by cryptomilk · Pull Request #19133 · python/cpython · GitHub

Repository navigation

bpo-40052: Fix alignment issue in PyVectorcall_Function() - #19133

Closed
cryptomilk wants to merge 1 commit into
python:masterfrom
cryptomilk:master-alignment
Closed

cryptomilk wants to merge 1 commit into
python:masterfrom
cryptomilk:master-alignment

Conversation

cryptomilk commented Mar 24, 2020 •
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Contributor
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.

https://bugs.python.org/issue40052

Copy link
Copy Markdown

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 username

We couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames:

@cryptomilk

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!

Copy link
Copy Markdown
Contributor Author

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.

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 <asn@cryptomilk.org>
ptr = (vectorcallfunc *)(((char *)callable) + offset);
return *ptr;
vc.data = (char *)callable + offset;
return *vc.ptr;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

(also, note that any decent compiler will optimize the memcpy call away)

Comment thread Objects/call.c
}
vectorcallfunc func = *(vectorcallfunc *)(((char *)callable) + offset);
vc.data = (char *)callable + offset;
vectorcallfunc func = *vc.ptr;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Same comment here.

Copy link
Copy Markdown

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 I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

And if you don't make the requested changes, you will be poked with soft cushions!

Copy link
Copy Markdown
Member

In my experience, memcpy() is good solution for such problem.

encukou commented Dec 29, 2020

Copy link
Copy Markdown
Member

I've made a PR with the suggested memcpy at #23999

pitrou commented Dec 29, 2020

Copy link
Copy Markdown
Member

Closing in favour of #23999.

pitrou closed this Dec 29, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants


Back | FazBrowse Home | New Git URL