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

Segfault from calling repr() on a dict with a key whose repr raise an exception #61060

Closed
dmcooke mannequin opened this issue Jan 3, 2013 · 6 comments
Closed

Segfault from calling repr() on a dict with a key whose repr raise an exception #61060

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

Comments

@dmcooke
Copy link
Mannequin

dmcooke mannequin commented Jan 3, 2013

BPO 16856
Nosy @tiran, @ezio-melotti, @bitdancer, @serhiy-storchaka, @dmcooke
Files
  • unicode_append.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 = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2013-01-04.10:48:32.675>
    created_at = <Date 2013-01-03.23:30:51.682>
    labels = ['interpreter-core', 'expert-unicode', 'type-crash']
    title = 'Segfault from calling repr() on a dict with a key whose repr raise an exception'
    updated_at = <Date 2013-01-04.10:48:32.674>
    user = 'https://github.com/dmcooke'

    bugs.python.org fields:

    activity = <Date 2013-01-04.10:48:32.674>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2013-01-04.10:48:32.675>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core', 'Unicode']
    creation = <Date 2013-01-03.23:30:51.682>
    creator = 'david.m.cooke'
    dependencies = []
    files = ['28555']
    hgrepos = []
    issue_num = 16856
    keywords = ['patch', '3.3regression']
    message_count = 6.0
    messages = ['178997', '178998', '179008', '179009', '179015', '179016']
    nosy_count = 6.0
    nosy_names = ['christian.heimes', 'ezio.melotti', 'r.david.murray', 'python-dev', 'serhiy.storchaka', 'david.m.cooke']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue16856'
    versions = ['Python 3.3', 'Python 3.4']

    @dmcooke
    Copy link
    Mannequin Author

    dmcooke mannequin commented Jan 3, 2013

    The following segfaults:

    class A(int):
        def __repr__(self):
            raise Exception()
    a = A()
    d = {a : 1}
    repr(d)

    This is with Python 3.3.0, running on Mac OS 10.7.5, from MacPorts:
    Python 3.3.0 (default, Sep 29 2012, 08:16:08)
    [GCC 4.2.1 Compatible Apple Clang 3.1 (tags/Apple/clang-318.0.58)] on darwin

    @dmcooke dmcooke 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 3, 2013
    @bitdancer
    Copy link
    Member

    Confirmed on Gentoo linux. On default, too. This is a regression from 3.2.

    @serhiy-storchaka
    Copy link
    Member

    Here is a patch.

    @tiran
    Copy link
    Member

    tiran commented Jan 4, 2013

    IMO the check is better performed a couple of lines later:

    if (right == NULL || left == NULL || !PyUnicode_Check(left)) {

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jan 4, 2013

    New changeset 3cee61137598 by Serhiy Storchaka in branch '3.3':
    Issue bpo-16856: Fix a segmentation fault from calling repr() on a dict with
    http://hg.python.org/cpython/rev/3cee61137598

    New changeset fee4bc043d73 by Serhiy Storchaka in branch 'default':
    Issue bpo-16856: Fix a segmentation fault from calling repr() on a dict with
    http://hg.python.org/cpython/rev/fee4bc043d73

    @serhiy-storchaka
    Copy link
    Member

    IMO the check is better performed a couple of lines later:

    Done.

    Thank you for report, David.

    @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) topic-unicode type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants