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 when stringifying UnicodeEncodeError (or UnicodeDecodeError) created with __new__() #65333

Closed
MarekKowalski mannequin opened this issue Apr 2, 2014 · 10 comments
Labels
topic-unicode type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@MarekKowalski
Copy link
Mannequin

MarekKowalski mannequin commented Apr 2, 2014

BPO 21134
Nosy @vstinner, @benjaminp, @ezio-melotti, @serhiy-storchaka
Files
  • segv.py: Minial script causing segfault
  • 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 2016-12-11.07:50:44.617>
    created_at = <Date 2014-04-02.14:10:37.666>
    labels = ['expert-unicode', 'type-crash']
    title = 'Segfault when stringifying UnicodeEncodeError (or UnicodeDecodeError) created with __new__()'
    updated_at = <Date 2016-12-11.07:50:44.616>
    user = 'https://bugs.python.org/MarekKowalski'

    bugs.python.org fields:

    activity = <Date 2016-12-11.07:50:44.616>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-12-11.07:50:44.617>
    closer = 'serhiy.storchaka'
    components = ['Unicode']
    creation = <Date 2014-04-02.14:10:37.666>
    creator = 'Marek.Kowalski'
    dependencies = []
    files = ['34702']
    hgrepos = []
    issue_num = 21134
    keywords = []
    message_count = 10.0
    messages = ['215384', '215386', '215389', '215390', '215391', '254675', '254695', '269421', '269424', '269426']
    nosy_count = 6.0
    nosy_names = ['vstinner', 'benjamin.peterson', 'ezio.melotti', 'python-dev', 'serhiy.storchaka', 'Marek.Kowalski']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue21134'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5']

    @MarekKowalski
    Copy link
    Mannequin Author

    MarekKowalski mannequin commented Apr 2, 2014

    I'm attaching a minimal script to reproduce. I tested only with 3.2 and 2.7 versions. Its possible that it has been fixed since 3.2.

    @MarekKowalski MarekKowalski mannequin added topic-unicode type-crash A hard crash of the interpreter, possibly with a core dump labels Apr 2, 2014
    @vstinner
    Copy link
    Member

    vstinner commented Apr 2, 2014

    Python 3.2 is not getting bugfixes anymore, only 3.4 and 3.5 (and 2.7).

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 2, 2014

    New changeset 140c5da3dc82 by Benjamin Peterson in branch '3.4':
    bail in unicode error's __str__ methods if the objects are not properly initialized (closes bpo-21134)
    http://hg.python.org/cpython/rev/140c5da3dc82

    New changeset afa7fb2cbe3b by Benjamin Peterson in branch '2.7':
    bail in unicode error's __str__ methods if the objects are not properly initialized (closes bpo-21134)
    http://hg.python.org/cpython/rev/afa7fb2cbe3b

    New changeset 0aeaea247d7d by Benjamin Peterson in branch 'default':
    merge 3.4 (bpo-21134)
    http://hg.python.org/cpython/rev/0aeaea247d7d

    @python-dev python-dev mannequin closed this as completed Apr 2, 2014
    @vstinner
    Copy link
    Member

    vstinner commented Apr 2, 2014

    Benjamin: I don't like your change. You silently ignore the error. I would prefer to raise an exception on str(exc) if the Unicode exception object was not properly initialized.

    @vstinner vstinner reopened this Apr 2, 2014
    @benjaminp
    Copy link
    Contributor

    I don't care as long as it doesn't segfault.

    @serhiy-storchaka
    Copy link
    Member

    Do you have a patch Victor?

    @vstinner
    Copy link
    Member

    Do you have a patch Victor?

    Nope.

    @serhiy-storchaka
    Copy link
    Member

    An empty string is the result of str() on an instance created with __new__ for all standard exceptions except SyntaxError (str() returnns 'None' for the latter, and this looks as a bug). Since there was no complains on this issue, I think it can be closed.

    @vstinner
    Copy link
    Member

    Since there was no complains on this issue, I think it can be closed.

    I have a complain: we should not ignore bugs. IMO an exception must be raised.

    @serhiy-storchaka
    Copy link
    Member

    What is the bug here (except fixed segfault)?

    @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-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