Skip to content

test_descr: test_vicious_descriptor_nonsense() fails randomly #80290

Closed

Description

@pablogsal
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']

    Activity

    1. pablogsal commented on Feb 25, 2019

      @pablogsal
      MemberAuthor

      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

    2. pablogsal commented on Feb 25, 2019

      @pablogsal
      MemberAuthor

      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

    3. pablogsal commented on Feb 25, 2019

      @pablogsal
      MemberAuthor

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

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

    4. pablogsal commented on Feb 26, 2019

      @pablogsal
      MemberAuthor

      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.

    5. pablogsal commented on Feb 26, 2019

      @pablogsal
      MemberAuthor

      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.

    6. pablogsal commented on Feb 26, 2019

      @pablogsal
      MemberAuthor

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

    7. pablogsal commented on Feb 26, 2019

      @pablogsal
      MemberAuthor

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

    8. changed the title [-]test_descr fails on AMD64 Windows8 3.x buildbots[/-] [+]test_descr: test_vicious_descriptor_nonsense() fails randomly[/+] on Feb 26, 2019
    9. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions