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

unchecked return value in C OrderedDict #68535

Closed
ericsnowcurrently opened this issue Jun 1, 2015 · 4 comments
Closed

unchecked return value in C OrderedDict #68535

ericsnowcurrently opened this issue Jun 1, 2015 · 4 comments
Assignees
Labels
release-blocker stdlib Python modules in the Lib dir type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@ericsnowcurrently
Copy link
Member

BPO 24347
Nosy @skrah, @ericsnowcurrently, @1st1
Files
  • crash-1.py
  • issue24347.dif
  • 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/ericsnowcurrently'
    closed_at = <Date 2015-06-02.05:07:09.162>
    created_at = <Date 2015-06-01.16:19:10.680>
    labels = ['library', 'type-crash', 'release-blocker']
    title = 'unchecked return value in C OrderedDict'
    updated_at = <Date 2015-06-02.05:07:09.161>
    user = 'https://github.com/ericsnowcurrently'

    bugs.python.org fields:

    activity = <Date 2015-06-02.05:07:09.161>
    actor = 'eric.snow'
    assignee = 'eric.snow'
    closed = True
    closed_date = <Date 2015-06-02.05:07:09.162>
    closer = 'eric.snow'
    components = ['Library (Lib)']
    creation = <Date 2015-06-01.16:19:10.680>
    creator = 'eric.snow'
    dependencies = []
    files = ['39588', '39591']
    hgrepos = []
    issue_num = 24347
    keywords = []
    message_count = 4.0
    messages = ['244597', '244604', '244627', '244649']
    nosy_count = 5.0
    nosy_names = ['Arfrever', 'skrah', 'python-dev', 'eric.snow', 'yselivanov']
    pr_nums = []
    priority = 'release blocker'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue24347'
    versions = ['Python 3.5', 'Python 3.6']

    @ericsnowcurrently
    Copy link
    Member Author

    (from msg244574 in bpo-16991)

    crash-1.py is due to an unchecked return value from _odictnode_VALUE().

    We should probably use PyDict_GetItemWithError(), also in other
    places.

    I normally try to steer clear of stylistic remarks, but the
    _odictnode* macros are hiding too many things. As of now,
    they were hiding that an assert() is always true and that a
    return value was unchecked.

    Also, they're very inconvenient in a debugger.

    @ericsnowcurrently ericsnowcurrently self-assigned this Jun 1, 2015
    @ericsnowcurrently ericsnowcurrently added stdlib Python modules in the Lib dir type-crash A hard crash of the interpreter, possibly with a core dump labels Jun 1, 2015
    @ericsnowcurrently
    Copy link
    Member Author

    Regarding the macros, my intent was to limit leaking the details of the linked list implementation and make it easier to change the linked list implementation later. However, if that results in problems then I'm open to changing it. What would you recommend?

    @ericsnowcurrently
    Copy link
    Member Author

    Using PyDict_GetItemWithError() is a good idea. Also, raising KeyError when the value is NULL (and no errors set) eliminates the crash. Here's a patch that fixes the problem. Unless there are any objections, I'll commit it in a couple hours.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jun 2, 2015

    New changeset 1a7c34e23ec9 by Eric Snow in branch '3.5':
    Issue bpo-24347: Set KeyError if PyDict_GetItemWithError returns NULL.
    https://hg.python.org/cpython/rev/1a7c34e23ec9

    @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
    release-blocker stdlib Python modules in the Lib dir type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant