Skip to content

An assertion failure in test_pickle #82565

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

Closed
ZackerySpytz mannequin opened this issue Oct 6, 2019 · 8 comments
Closed

An assertion failure in test_pickle #82565

ZackerySpytz mannequin opened this issue Oct 6, 2019 · 8 comments
Labels
3.11 only security fixes 3.12 only security fixes easy extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error

Comments

@ZackerySpytz
Copy link
Mannequin

ZackerySpytz mannequin commented Oct 6, 2019

BPO 38384
Nosy @taleinat, @serhiy-storchaka, @phmc, @ZackerySpytz, @iritkatriel
PRs
  • gh-82565: Fix a possible assertion failure in _pickle #16606
  • 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 = None
    created_at = <Date 2019-10-06.13:39:09.443>
    labels = ['extension-modules', '3.10', '3.9', 'type-crash', '3.11']
    title = 'An assertion failure in test_pickle'
    updated_at = <Date 2021-10-19.09:07:52.229>
    user = 'https://github.com/ZackerySpytz'

    bugs.python.org fields:

    activity = <Date 2021-10-19.09:07:52.229>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Extension Modules']
    creation = <Date 2019-10-06.13:39:09.443>
    creator = 'ZackerySpytz'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38384
    keywords = ['patch']
    message_count = 4.0
    messages = ['354038', '354040', '357337', '404277']
    nosy_count = 5.0
    nosy_names = ['taleinat', 'serhiy.storchaka', 'pconnell', 'ZackerySpytz', 'iritkatriel']
    pr_nums = ['16606']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue38384'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    Linked PRs

    @ZackerySpytz
    Copy link
    Mannequin Author

    ZackerySpytz mannequin commented Oct 6, 2019

    When running test_pickle, I sometimes see an assertion failure.

    ./python -m test test_pickle
    0:00:00 load avg: 1.04 Run tests sequentially
    0:00:00 load avg: 1.04 [1/1] test_pickle
    python: Objects/typeobject.c:3151: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.
    Fatal Python error: Aborted

    Current thread 0x00007f8158632140 (most recent call first):
    File "/home/lubuntu2/cpython/Lib/test/pickletester.py", line 3400 in test_unpickling_buffering_readline
    File "/home/lubuntu2/cpython/Lib/unittest/case.py", line 617 in _callTestMethod
    File "/home/lubuntu2/cpython/Lib/unittest/case.py", line 663 in run
    File "/home/lubuntu2/cpython/Lib/unittest/case.py", line 725 in __call__
    File "/home/lubuntu2/cpython/Lib/unittest/suite.py", line 122 in run
    File "/home/lubuntu2/cpython/Lib/unittest/suite.py", line 84 in __call__
    File "/home/lubuntu2/cpython/Lib/unittest/suite.py", line 122 in run
    File "/home/lubuntu2/cpython/Lib/unittest/suite.py", line 84 in __call__
    File "/home/lubuntu2/cpython/Lib/test/support/testresult.py", line 162 in run
    File "/home/lubuntu2/cpython/Lib/test/support/init.py", line 2032 in _run_suite
    File "/home/lubuntu2/cpython/Lib/test/support/init.py", line 2128 in run_unittest
    File "/home/lubuntu2/cpython/Lib/test/test_pickle.py", line 525 in test_main
    File "/home/lubuntu2/cpython/Lib/test/libregrtest/runtest.py", line 234 in _runtest_inner2
    File "/home/lubuntu2/cpython/Lib/test/libregrtest/runtest.py", line 270 in _runtest_inner
    File "/home/lubuntu2/cpython/Lib/test/libregrtest/runtest.py", line 153 in _runtest
    File "/home/lubuntu2/cpython/Lib/test/libregrtest/runtest.py", line 193 in runtest
    File "/home/lubuntu2/cpython/Lib/test/libregrtest/main.py", line 417 in run_tests_sequential
    File "/home/lubuntu2/cpython/Lib/test/libregrtest/main.py", line 515 in run_tests
    File "/home/lubuntu2/cpython/Lib/test/libregrtest/main.py", line 687 in _main
    File "/home/lubuntu2/cpython/Lib/test/libregrtest/main.py", line 634 in main
    File "/home/lubuntu2/cpython/Lib/test/libregrtest/main.py", line 712 in main
    File "/home/lubuntu2/cpython/Lib/test/main.py", line 2 in <module>
    File "/home/lubuntu2/cpython/Lib/runpy.py", line 85 in _run_code
    File "/home/lubuntu2/cpython/Lib/runpy.py", line 192 in _run_module_as_main
    Aborted (core dumped)

    In _Unpickler_SetInputStream(), _PyObject_LookupAttrId() is called three times in a row without any error handling.
    If an exception occurs during the first or second call, _PyObject_LookupAttrId() will be called with a live exception.

    @ZackerySpytz ZackerySpytz mannequin added 3.7 (EOL) end of life 3.8 (EOL) end of life 3.9 only security fixes extension-modules C modules in the Modules dir type-crash A hard crash of the interpreter, possibly with a core dump labels Oct 6, 2019
    @serhiy-storchaka
    Copy link
    Member

    I do not understand how you got an assertion failure. Did you interrupt tests with Ctrl-C?

    @taleinat
    Copy link
    Contributor

    Good catch on this, Zackery!

    For anyone readying this, Serhiy posted a minimal reproducer in a PR comment, and the PR now adds a test for this.

    @iritkatriel
    Copy link
    Member

    Reproduced on 3.11 with Serhiy's reproducer:

    class F:
        @property
        def read(self):
            1/0
    
    import pickle
    pickle.load(F())

    @iritkatriel iritkatriel added 3.10 only security fixes 3.11 only security fixes and removed 3.7 (EOL) end of life 3.8 (EOL) end of life labels Oct 19, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @iritkatriel iritkatriel added type-bug An unexpected behavior, bug, or error 3.12 only security fixes and removed 3.9 only security fixes labels Mar 1, 2023
    @iritkatriel
    Copy link
    Member

    The PR is almost there but need a few more tests. The OP is no longer responding, so I am marking as easy for someone new to finish it.

    @SahillMulani
    Copy link

    SahillMulani commented Apr 3, 2023

    Please check the below code test cases

    File without read and readline

    • Please help me with this test case

    File with bad read and without readline

        class F:  
            read = bad_property
        self.assertRaises(ZeroDivisionError, self.Unpickler, F())
    

    File with bad readline and without read

        class F: 
            readline = bad_property
        self.assertRaises(ZeroDivisionError, self.Unpickler, F())
    

    @ZackerySpytz
    Copy link
    Contributor

    I plan on updating my PR within the next two weeks.

    @SahillMulani Please find a different issue to work on.

    @arhadthedev arhadthedev removed 3.10 only security fixes type-crash A hard crash of the interpreter, possibly with a core dump labels Apr 20, 2023
    miss-islington pushed a commit to miss-islington/cpython that referenced this issue Dec 1, 2023
    miss-islington pushed a commit to miss-islington/cpython that referenced this issue Dec 1, 2023
    @serhiy-storchaka
    Copy link
    Member

    The original issue was fixed in #105667, but good tests are useful.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes 3.12 only security fixes easy extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error
    Projects
    Status: Done
    Development

    No branches or pull requests

    6 participants