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
Comments
https://buildbot.python.org/all/#/builders/32/builds/2198 ====================================================================== 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 |
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: Total duration: 2 sec 437 ms |
It seems that this is a race condition created as a consequence of: |
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. |
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. |
A lot of buildbots were failing for this test so a lot of them will become green after ff3d39f. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: