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 when unicode(classic_class_instance) #61043

Closed
draftcode mannequin opened this issue Jan 2, 2013 · 3 comments
Closed

segmentation fault when unicode(classic_class_instance) #61043

draftcode mannequin opened this issue Jan 2, 2013 · 3 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@draftcode
Copy link
Mannequin

draftcode mannequin commented Jan 2, 2013

BPO 16839
Nosy @jcea, @benjaminp
Files
  • object_unicode.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 = <Date 2013-01-02.15:37:52.577>
    created_at = <Date 2013-01-02.13:50:36.115>
    labels = ['interpreter-core', 'type-crash']
    title = 'segmentation fault when unicode(classic_class_instance)'
    updated_at = <Date 2013-01-02.20:44:45.728>
    user = 'https://bugs.python.org/draftcode'

    bugs.python.org fields:

    activity = <Date 2013-01-02.20:44:45.728>
    actor = 'jcea'
    assignee = 'none'
    closed = True
    closed_date = <Date 2013-01-02.15:37:52.577>
    closer = 'python-dev'
    components = ['Interpreter Core']
    creation = <Date 2013-01-02.13:50:36.115>
    creator = 'draftcode'
    dependencies = []
    files = ['28528']
    hgrepos = []
    issue_num = 16839
    keywords = ['patch']
    message_count = 3.0
    messages = ['178811', '178817', '178818']
    nosy_count = 4.0
    nosy_names = ['jcea', 'benjamin.peterson', 'python-dev', 'draftcode']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue16839'
    versions = ['Python 2.7']

    @draftcode
    Copy link
    Mannequin Author

    draftcode mannequin commented Jan 2, 2013

    Python 2.7.3 crushes when the following code is run without any library, which means run python with -S option:

        class Test:
            pass
        unicode(Test())

    In the course of the interpreter tries to find the "__unicode__" attribute in a class, it uses a cached python string of "__unicode__". The reason of this crush is that the cached value is used before initialized. It is initialized only when trying to find the one of a new-style class, so the interpreter will crush if one uses only classic classes.

    The attached patch will fix this issue by initializing a cached value before it is used.

    Thanks.

    @draftcode draftcode mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump labels Jan 2, 2013
    @benjaminp
    Copy link
    Contributor

    Thank you for the bug report.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jan 2, 2013

    New changeset 0012d4f0ca59 by Benjamin Peterson in branch '2.7':
    ensure the attribute name string is initalized before using it (closes bpo-16839)
    http://hg.python.org/cpython/rev/0012d4f0ca59

    @python-dev python-dev mannequin closed this as completed Jan 2, 2013
    @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
    interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant