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

test_descr: test_vicious_descriptor_nonsense() fails randomly #80290

Closed
pablogsal opened this issue Feb 25, 2019 · 7 comments
Closed

test_descr: test_vicious_descriptor_nonsense() fails randomly #80290

pablogsal opened this issue Feb 25, 2019 · 7 comments
Labels
3.8 only security fixes OS-windows tests Tests in the Lib/test dir

Comments

@pablogsal
Copy link
Member

BPO 36109
Nosy @pfmoore, @tjguk, @zware, @serhiy-storchaka, @zooba, @pablogsal
PRs
  • bpo-36109: Fix random test_descr failure. #12044
  • 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 2019-02-26.06:03:51.242>
    created_at = <Date 2019-02-25.21:15:44.730>
    labels = ['3.8', 'tests', 'OS-windows']
    title = 'test_descr: test_vicious_descriptor_nonsense() fails randomly'
    updated_at = <Date 2019-02-26.10:55:55.419>
    user = 'https://github.com/pablogsal'

    bugs.python.org fields:

    activity = <Date 2019-02-26.10:55:55.419>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-02-26.06:03:51.242>
    closer = 'pablogsal'
    components = ['Tests', 'Windows']
    creation = <Date 2019-02-25.21:15:44.730>
    creator = 'pablogsal'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 36109
    keywords = ['patch']
    message_count = 7.0
    messages = ['336554', '336557', '336560', '336609', '336612', '336613', '336614']
    nosy_count = 6.0
    nosy_names = ['paul.moore', 'tim.golden', 'zach.ware', 'serhiy.storchaka', 'steve.dower', 'pablogsal']
    pr_nums = ['12044']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue36109'
    versions = ['Python 3.8']

    @pablogsal
    Copy link
    Member Author

    https://buildbot.python.org/all/#/builders/32/builds/2198

    ======================================================================
    ERROR: test_vicious_descriptor_nonsense (test.test_descr.ClassPropertiesAndMethods)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "D:\buildarea\3.x.bolen-windows8\build\lib\test\test_descr.py", line 4341, in test_vicious_descriptor_nonsense
        self.assertEqual(c.attr, 1)
      File "D:\buildarea\3.x.bolen-windows8\build\lib\test\test_descr.py", line 4328, in __eq__
        del C.attr
    AttributeError: attr

    Ran 140 tests in 7.836s

    @pablogsal pablogsal added 3.8 only security fixes tests Tests in the Lib/test dir OS-windows labels Feb 25, 2019
    @pablogsal
    Copy link
    Member Author

    I can reproduce this locally. How has this not being spotted by the CI:

    ❯ ./python.exe -m test test_descr
    Run tests sequentially
    0:00:00 load avg: 3.82 [1/1] test_descr
    test test_descr failed -- Traceback (most recent call last):
      File "/Users/pgalindo3/github/cpython/Lib/test/test_descr.py", line 4341, in test_vicious_descriptor_nonsense
        self.assertEqual(c.attr, 1)
      File "/Users/pgalindo3/github/cpython/Lib/test/test_descr.py", line 4328, in __eq__
        del C.attr
    AttributeError: attr

    test_descr failed

    == Tests result: FAILURE ==

    1 test failed:
    test_descr

    Total duration: 2 sec 437 ms
    Tests result: FAILURE

    @pablogsal
    Copy link
    Member Author

    It seems that this is a race condition created as a consequence of:

    https://github.com/python/cpython/pull/11112/files

    @pablogsal
    Copy link
    Member Author

    Although 12044 fixes the problem, something a bit more fundamental may have changed. I have spent time investigating why this is happening and the problem is that in the line:

    self.assertEqual(c.attr, 1)

    Evil.__eq__ is invoked twice where before it was only invoked once. This does not happen all the time, and it seems to only happen under some combination of hashes in the class dictionary, being the extra __eq__ invocation a check for equality when looking up attr in the c object. When the test succeeds, the extra check is not done (and therefore the attribute is not deleted). I think this happens because some identity is used to check when doing the lookup (comparing the pointers) but I would like to understand exactly how the hash is influencing the different code paths to be sure that nothing important has changed recently.

    @pablogsal
    Copy link
    Member Author

    Ok, actually this turns to be much easier: Sometimes __eq__ was also called twice but now as we use PyDict_GetItemWithError instead of PyDict_GetItem, if the extra __eq__ happens as a consequence of a dict lookup the error is ignored so that was the reason the test was not failing before.

    @pablogsal
    Copy link
    Member Author

    New changeset ff3d39f by Pablo Galindo (Serhiy Storchaka) in branch 'master':
    bpo-36109: Fix random test_descr failure. (GH-12044)
    ff3d39f

    @pablogsal
    Copy link
    Member Author

    A lot of buildbots were failing for this test so a lot of them will become green after ff3d39f.

    @vstinner vstinner changed the title test_descr fails on AMD64 Windows8 3.x buildbots test_descr: test_vicious_descriptor_nonsense() fails randomly Feb 26, 2019
    @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
    3.8 only security fixes OS-windows tests Tests in the Lib/test dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant