Skip to content

test_type_cache fails with --forever argument #113937

Closed

Description

@Eclips4

Bug report

Bug description:

Trace:

./python.exe -m test -q test_type_cache --forever
Using random seed: 2064316463
0:00:00 load avg: 2.54 Run tests sequentially
test test_type_cache failed -- Traceback (most recent call last):
  File "/Users/admin/Projects/cpython/Lib/test/test_type_cache.py", line 132, in test_class_load_attr_specialization_static_type
    self._assign_and_check_valid_version(str)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/Users/admin/Projects/cpython/Lib/test/test_type_cache.py", line 90, in _assign_and_check_valid_version
    self.assertNotEqual(type_get_version(user_type), 0)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 0 == 0


== Tests result: FAILURE ==

1 test failed:
    test_type_cache

Total duration: 50 ms
Total tests: run=14 failures=1
Total test files: run=2 failed=1
Result: FAILURE

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    testsTests in the Lib/test dir
    on Jan 11, 2024
  2. Eclips4 commented on Jan 11, 2024

    @Eclips4
    MemberAuthor

    Seems to be introduced in #113558. This PR should be backported to 3.11 and 3.12 (but not backported yet), that's why I'm adding 3.11 & 3.12 labels.

    Theoretically it may not be reproducible on 3.11 (maybe some deep internal changes were made) I'll check it when backports will be done.

  3. added
    3.11only security fixes
    3.12only security fixes
    3.13only security fixes
    on Jan 11, 2024
  4. Eclips4 commented on Jan 11, 2024

    @Eclips4
    MemberAuthor

    Another error also occurs if we run this test using -R 3:3:

    FAIL: test_property_load_attr_specialization_user_type (test.test_type_cache.TypeCacheWithSpecializationTests.test_property_load_attr_specialization_user_type)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/Users/admin/Projects/cpython/Lib/test/test_type_cache.py", line 172, in test_property_load_attr_specialization_user_type
        self._check_specialization(load_x_1, G(), "LOAD_ATTR", should_specialize=True)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/admin/Projects/cpython/Lib/test/test_type_cache.py", line 101, in _check_specialization
        self.assertIn(opname, self._all_opnames(func))
        ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    AssertionError: 'LOAD_ATTR' not found in {'LOAD_FAST', 'RETURN_CONST', 'POP_TOP', 'RESUME_CHECK', 'LOAD_ATTR_PROPERTY'}
  5. Fidget-Spinner commented on Jan 11, 2024

    @Fidget-Spinner
    Member

    Thanks for the report. I'll take a look.

  6. lazorchakp commented on Jan 11, 2024

    @lazorchakp
    Contributor

    Sorry for this - I certainly introduced it. The first issue should be resolvable by skipping tests if we run out of version tags (like what was done in the preexisting test_tp_version_tag_unique). I'm not sure what could be causing the second, though. @Fidget-Spinner if you'd like another set of eyes on this, lmk

  7. Fidget-Spinner commented on Jan 11, 2024

    @Fidget-Spinner
    Member

    @lazorchakp if you'd like to submit a PR to fix it I would be happy to review it as well! For the second case, it's possible that the specialization has not reverted yet. In CPython, code objects are shared across functions (so every time you create a new function, it reuses the same code object, you can dis.dis a closure to see what I mean). So the specialization from a previous iteration could stick around for abit until it de-specializes by running the loop a few times. Because of that, I think it's fine to remove that line.

  8. lazorchakp commented on Jan 11, 2024

    @lazorchakp
    Contributor

    Oh that's interesting! I should be able to get a PR open pretty quickly

  9. added a commit that references this issue on Jan 11, 2024
  10. added a commit that references this issue on Jan 12, 2024
  11. encukou commented on Jan 12, 2024

    @encukou
    Member

    test_type_cache seems to be failing for pretty much all the refleak buildbots, probably due to this fix.
    @Fidget-Spinner, please let me know if you need help.

  12. Eclips4 commented on Jan 12, 2024

    @Eclips4
    MemberAuthor

    test_type_cache seems to be failing for pretty much all the refleak buildbots, probably due to this fix. @Fidget-Spinner, please let me know if you need help.

    Can you share link to the failing buildbot, please? I cannot reproduce it locally

  13. encukou commented on Jan 12, 2024

    @encukou
    Member

    Oh, I read the wrong timestamp in my buildbot triage :(
    Sorry for the alarm!

  14. added a commit that references this issue on Jan 17, 2024
  15. added a commit that references this issue on Jan 22, 2024
  16. added a commit that references this issue on Feb 5, 2024
  17. added a commit that references this issue on Feb 6, 2024
  18. added a commit that references this issue on Feb 11, 2024
  19. added a commit that references this issue on Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

3.11only security fixes3.12only security fixes3.13only security fixestestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions