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 with defaultdict and pickle #48420

Closed
erickt mannequin opened this issue Oct 22, 2008 · 7 comments
Closed

segfault with defaultdict and pickle #48420

erickt mannequin opened this issue Oct 22, 2008 · 7 comments
Labels
stdlib Python modules in the Lib dir type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@erickt
Copy link
Mannequin

erickt mannequin commented Oct 22, 2008

BPO 4170
Nosy @amauryfa
Files
  • fix_defaultdict_reduce.patch
  • fix_defaultdict_reduce_v2.patch: also test with HIGHEST_PROTOCOL
  • 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 2008-10-30.20:58:54.660>
    created_at = <Date 2008-10-22.09:26:46.700>
    labels = ['library', 'type-crash']
    title = 'segfault with defaultdict and pickle'
    updated_at = <Date 2008-10-30.20:58:54.659>
    user = 'https://bugs.python.org/erickt'

    bugs.python.org fields:

    activity = <Date 2008-10-30.20:58:54.659>
    actor = 'amaury.forgeotdarc'
    assignee = 'none'
    closed = True
    closed_date = <Date 2008-10-30.20:58:54.660>
    closer = 'amaury.forgeotdarc'
    components = ['Library (Lib)']
    creation = <Date 2008-10-22.09:26:46.700>
    creator = 'erickt'
    dependencies = []
    files = ['11856', '11864']
    hgrepos = []
    issue_num = 4170
    keywords = ['patch']
    message_count = 7.0
    messages = ['75073', '75076', '75086', '75087', '75095', '75126', '75380']
    nosy_count = 3.0
    nosy_names = ['amaury.forgeotdarc', 'ocean-city', 'erickt']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue4170'
    versions = ['Python 3.0']

    @erickt
    Copy link
    Mannequin Author

    erickt mannequin commented Oct 22, 2008

    It seems like there's a bug with defaultdict. This is segfaulting with
    the latest python 3.0 svn checkout:

    import collections, pickle
    d=collections.defaultdict(int)
    d[1]
    pickle.dumps(d)

    It errors out with:

    Assertion failed: (PyIter_Check(iter)), function PyIter_Next, file
    Objects/abstract.c, line 2751.
    zsh: abort /tmp/python/bin/python3.0 foo.py

    @erickt erickt mannequin added stdlib Python modules in the Lib dir type-crash A hard crash of the interpreter, possibly with a core dump labels Oct 22, 2008
    @ocean-city
    Copy link
    Mannequin

    ocean-city mannequin commented Oct 22, 2008

    On py3k, defaultdict#items() returns dict_items object not
    dict_itemiterator object. I hope attached patch will fix this bug.

    @amauryfa
    Copy link
    Member

    The pickle protocol should also check that __reduce__ returns iterators
    (iterables are not enough).
    The code below crashes the interpreter (twice ;-)

    class C:
        def __reduce__(self):
            return C, (), None, None, []
    class D:
        def __reduce__(self):
            return D, (), None, [], None
    import pickle
    pickle.dumps(C())
    pickle.dumps(D())

    @amauryfa
    Copy link
    Member

    My previous example also crashes python 2.4 & 2.6 (the classes have to
    inherit from 'object')

    @ocean-city
    Copy link
    Mannequin

    ocean-city mannequin commented Oct 22, 2008

    My previous example also crashes python 2.4 & 2.6 (the classes have to
    inherit from 'object')

    I created new tracker item for this. (See bpo-4176)

    @ocean-city
    Copy link
    Mannequin

    ocean-city mannequin commented Oct 23, 2008

    I created test case referring to test_bytes, but I noticed
    range(pickle.HIGHETST_PROTOCOL) doesn't test HIGHEST_PROTOCOL itself. So
    patch revised. I created another tracker item for other tests using
    range(pickle.HIGHETST_PROTOCOL). See bpo-4183.

    @amauryfa
    Copy link
    Member

    Fixed with r67048.

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