Visitar URL original
ctypes: structure with bitfields as argument · Issue #60780 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20220427043900/https://github.com/python/cpython/issues/60780
Skip to content
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

ctypes: structure with bitfields as argument #60780

Open
arigo mannequin opened this issue Nov 29, 2012 · 10 comments
Open

ctypes: structure with bitfields as argument #60780

arigo mannequin opened this issue Nov 29, 2012 · 10 comments
Labels
3.7 3.8 3.9 expert-ctypes type-crash

Comments

@arigo
Copy link
Mannequin

@arigo arigo mannequin commented Nov 29, 2012

BPO 16576
Nosy @arigo, @theller, @vsajip, @amauryfa, @abalkin, @alex, @meadori
PRs
  • #15839
  • #17097
  • #17223
  • #17224
  • Files
  • test185_lib.tgz
  • test186_lib.tgz
  • issue16576.docfix.1.patch
  • 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:

    assignee = None
    closed_at = None
    created_at = <Date 2012-11-29.04:53:32.056>
    labels = ['ctypes', '3.7', '3.8', '3.9', 'type-crash']
    title = 'ctypes: structure with bitfields as argument'
    updated_at = <Date 2020-01-12.07:46:05.510>
    user = 'https://github.com/arigo'

    bugs.python.org fields:

    activity = <Date 2020-01-12.07:46:05.510>
    actor = 'vinay.sajip'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['ctypes']
    creation = <Date 2012-11-29.04:53:32.056>
    creator = 'arigo'
    dependencies = []
    files = ['28156', '28157', '29326']
    hgrepos = []
    issue_num = 16576
    keywords = ['patch']
    message_count = 10.0
    messages = ['176629', '176631', '183595', '183665', '183816', '183818', '356447', '356869', '357224', '359835']
    nosy_count = 10.0
    nosy_names = ['arigo', 'theller', 'vinay.sajip', 'amaury.forgeotdarc', 'belopolsky', 'Arfrever', 'alex', 'eli.bendersky', 'meador.inge', 'python-dev']
    pr_nums = ['15839', '17097', '17223', '17224']
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue16576'
    versions = ['Python 3.7', 'Python 3.8', 'Python 3.9']

    @arigo
    Copy link
    Mannequin Author

    @arigo arigo mannequin commented Nov 29, 2012

    ctypes pretends to support passing arguments to C functions that are structures containing bitfields, or at least does not explicitly forbid it. But doing so results in misbehavior or segfaults in libffi itself. Indeed, libffi has no support for this, and ctypes just describes a field like "int x:1;" as "int x;". The attached example segfaults on Linux x86-64.

    @arigo arigo mannequin added expert-ctypes type-crash labels Nov 29, 2012
    @arigo
    Copy link
    Mannequin Author

    @arigo arigo mannequin commented Nov 29, 2012

    The same misbehavior occurs if the structures are packed ("_pack_ = 1"). Attached in test186_lib.tgz.

    @elibendersky
    Copy link
    Mannequin

    @elibendersky elibendersky mannequin commented Mar 6, 2013

    I propose to start with the attached documentation fix (generated vs. 3.2 but should be applied to all active branches).

    A code fix has to be discussed more thoroughly because in theory some code running only on x86-32 can rely on it and will break.

    @elibendersky
    Copy link
    Mannequin

    @elibendersky elibendersky mannequin commented Mar 7, 2013

    The patch addresses bpo-16575 as well

    @python-dev
    Copy link
    Mannequin

    @python-dev python-dev mannequin commented Mar 9, 2013

    New changeset 0acd9408b6f1 by Eli Bendersky in branch '3.2':
    Add warning in ctypes documentation for bpo-16575 and bpo-16576
    http://hg.python.org/cpython/rev/0acd9408b6f1

    New changeset bfc159f8e4b4 by Eli Bendersky in branch '3.3':
    Add warning in ctypes documentation for bpo-16575 and bpo-16576
    http://hg.python.org/cpython/rev/bfc159f8e4b4

    New changeset 502624235c7b by Eli Bendersky in branch 'default':
    Add warning in ctypes documentation for bpo-16575 and bpo-16576
    http://hg.python.org/cpython/rev/502624235c7b

    @python-dev
    Copy link
    Mannequin

    @python-dev python-dev mannequin commented Mar 9, 2013

    New changeset eece32440a52 by Eli Bendersky in branch '2.7':
    Add warning in ctypes documentation for bpo-16575 and bpo-16576
    http://hg.python.org/cpython/rev/eece32440a52

    @vsajip
    Copy link
    Member

    @vsajip vsajip commented Nov 12, 2019

    New changeset 1062715 by Vinay Sajip in branch 'master':
    bpo-16576: Add checks for bitfields passed by value to functions. (GH-17097)
    1062715

    @vsajip
    Copy link
    Member

    @vsajip vsajip commented Nov 18, 2019

    New changeset bef2815 by Vinay Sajip (Miss Islington (bot)) in branch '3.8':
    bpo-16576: Add checks for bitfields passed by value to functions. (GH-17097) (GH-17223)
    bef2815

    @vsajip
    Copy link
    Member

    @vsajip vsajip commented Nov 21, 2019

    New changeset 91c15a5 by Vinay Sajip (Miss Islington (bot)) in branch '3.7':
    [3.7] bpo-16576: Add checks for bitfields passed by value to functions. (GH-17097) (GH-17224)
    91c15a5

    @vsajip vsajip closed this Nov 21, 2019
    @vsajip
    Copy link
    Member

    @vsajip vsajip commented Jan 12, 2020

    The issue is being reopened, see this comment on bpo-16575:

    https://bugs.python.org/msg359834

    @vsajip vsajip reopened this Jan 12, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 3.8 3.9 expert-ctypes type-crash
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant