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.

classification
Title: Incorrect pointer alignment in _PyVectorcall_Function() of cpython/abstract.h
Type: compile error Stage: resolved
Components: C API Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: asn, eamanu, mcepl, miss-islington, petr.viktorin, python-dev
Priority: normal Keywords: patch

Created on 2020-03-24 06:58 by asn, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 19133 closed python-dev, 2020-03-24 06:59
PR 19179 closed mcepl, 2020-03-26 17:05
PR 23999 merged petr.viktorin, 2020-12-29 16:43
PR 24005 merged miss-islington, 2020-12-29 23:32
PR 24120 merged petr.viktorin, 2021-01-05 15:54
Messages (7)
msg364919 - (view) Author: Andreas Schneider (asn) * Date: 2020-03-24 06:58
In file included from /builds/cryptomilk/pam_wrapper/src/python/pypamtest.c:21:
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.


The correct way to do it would be:

union {
   char *data;
   vectorcallfunc *ptr;
} vc;

vc.data = (char *)callable + offset;
return *vc.ptr;
msg364954 - (view) Author: Emmanuel Arias (eamanu) * Date: 2020-03-24 17:34
Hi! I cannot reproduce the error. Could you provide the way to reproduce?

thanks
msg364963 - (view) Author: Andreas Schneider (asn) * Date: 2020-03-24 21:04
clang -Werror -Wcast-align ...

rpm -q clang9
clang9-9.0.1-8.1.x86_64

Does that help? Found in CI of

https://gitlab.com/cwrap/pam_wrapper
msg364977 - (view) Author: Andreas Schneider (asn) * Date: 2020-03-25 05:49
I forgot, for detecting alignment issues or strict aliasing and this also falls under strict aliasing, you need to turn on optimizations.

clang -O2 -Werror -Wcast-align ...
msg384033 - (view) Author: miss-islington (miss-islington) Date: 2020-12-29 23:32
New changeset 056c08211b402b4dbc1530a9de9d00ad5309909f by Petr Viktorin in branch 'master':
bpo-40052: Fix alignment issue in PyVectorcall_Function() (GH-23999)
https://github.com/python/cpython/commit/056c08211b402b4dbc1530a9de9d00ad5309909f
msg384410 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2021-01-05 15:47
New changeset 6e72ab909de58e89b5a7cd6899587e203cf129a3 by Miss Islington (bot) in branch '3.9':
[3.9] bpo-40052: Fix alignment issue in PyVectorcall_Function() (GH-23999) (GH-24005)
https://github.com/python/cpython/commit/6e72ab909de58e89b5a7cd6899587e203cf129a3
msg384945 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2021-01-12 14:45
New changeset 187f76def8a5bd0af7ab512575cad30cfe624b05 by Petr Viktorin in branch '3.8':
[3.8] bpo-40052: Fix alignment issue in PyVectorcall_Function() (GH-23999) (GH-24120)
https://github.com/python/cpython/commit/187f76def8a5bd0af7ab512575cad30cfe624b05
History
Date User Action Args
2022-04-11 14:59:28adminsetgithub: 84233
2021-01-14 12:19:39petr.viktorinsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-01-12 14:45:12petr.viktorinsetmessages: + msg384945
2021-01-05 15:54:25petr.viktorinsetpull_requests: + pull_request22951
2021-01-05 15:47:22petr.viktorinsetmessages: + msg384410
2020-12-29 23:32:25miss-islingtonsetpull_requests: + pull_request22847
2020-12-29 23:32:19miss-islingtonsetnosy: + miss-islington
messages: + msg384033
2020-12-29 16:43:53petr.viktorinsetnosy: + petr.viktorin
pull_requests: + pull_request22841
2020-03-26 17:05:29mceplsetnosy: + mcepl
pull_requests: + pull_request18539
2020-03-25 05:49:25asnsetmessages: + msg364977
2020-03-24 21:04:16asnsetmessages: + msg364963
2020-03-24 17:34:44eamanusetnosy: + eamanu
messages: + msg364954
2020-03-24 07:40:31asnsettype: compile error
versions: + Python 3.8
2020-03-24 06:59:55python-devsetkeywords: + patch
nosy: + python-dev

pull_requests: + pull_request18494
stage: patch review
2020-03-24 06:58:12asncreate