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

Segmentation fault on ctypes.Structure subclass with byte string field names #58768

Closed
aliles mannequin opened this issue Apr 12, 2012 · 4 comments
Closed

Segmentation fault on ctypes.Structure subclass with byte string field names #58768

aliles mannequin opened this issue Apr 12, 2012 · 4 comments
Labels
topic-ctypes type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@aliles
Copy link
Mannequin

aliles mannequin commented Apr 12, 2012

BPO 14563
Nosy @amauryfa
Files
  • segfault.py: Script that will cause a segmentation fault.
  • 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 = <Date 2012-08-21.00:50:15.259>
    created_at = <Date 2012-04-12.13:11:02.042>
    labels = ['ctypes', 'type-crash']
    title = 'Segmentation fault on ctypes.Structure subclass with byte string field names'
    updated_at = <Date 2012-08-21.00:50:15.257>
    user = 'https://bugs.python.org/aliles'

    bugs.python.org fields:

    activity = <Date 2012-08-21.00:50:15.257>
    actor = 'aliles'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-08-21.00:50:15.259>
    closer = 'aliles'
    components = ['ctypes']
    creation = <Date 2012-04-12.13:11:02.042>
    creator = 'aliles'
    dependencies = []
    files = ['25189']
    hgrepos = []
    issue_num = 14563
    keywords = []
    message_count = 4.0
    messages = ['158127', '158173', '158184', '168723']
    nosy_count = 2.0
    nosy_names = ['amaury.forgeotdarc', 'aliles']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue14563'
    versions = ['Python 3.2']

    @aliles
    Copy link
    Mannequin Author

    aliles mannequin commented Apr 12, 2012

    Python 3.2 will exit with a segmentation fault if a byte string is used as a field name in a subclass of ctypes.Structure.

    Python 3.2.2 (default, Dec 18 2011, 18:56:20) 
    [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import ctypes
    >>> class Point(ctypes.Structure):
    ...     _fields_ = ((b'x', ctypes.c_int), (b'y', ctypes.c_int))
    ... 
    Segmentation fault: 11

    This also occurs if None or an int is used as the field name.

    I would expect that a TypeError exception would be raised if an attempt is made to use an invalid type for the field name.

    @aliles aliles mannequin added topic-ctypes type-crash A hard crash of the interpreter, possibly with a core dump labels Apr 12, 2012
    @amauryfa
    Copy link
    Member

    This is a duplicate of bpo-12764, which was already fixed for 3.2.2 (in September 2011)
    Which version of python are you using exactly?
    What does "import platform; platform.python_revision()" return?

    @aliles
    Copy link
    Mannequin Author

    aliles mannequin commented Apr 12, 2012

    Should I build a version from the tip of the 3.2 or default branch on hg.python.org?

    This version is Python 3.2.2 built using homebrew. The revision is being reported as an empty string.

    Python 3.2.2 (default, Dec 18 2011, 18:56:20) 
    [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import platform
    >>> platform.python_revision()
    ''
    >>> platform.python_version_tuple()
    ('3', '2', '2')
    >>> platform.python_build()
    ('default', 'Dec 18 2011 18:56:20')
    >>> platform.release()
    '11.3.0'
    >>> platform.version()
    'Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64'

    Sorry, I did a search but didn't find bpo-12764. :-(

    @aliles
    Copy link
    Mannequin Author

    aliles mannequin commented Aug 21, 2012

    Tested with Python 3.3b2 built from trunk. This issue is resolved.

    @aliles aliles mannequin closed this as completed Aug 21, 2012
    @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
    topic-ctypes type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant