Skip to content

test_interpreters.test_stress Crashes in managed_static_type_state_clear() #127108

Open
@ericsnowcurrently

Description

@ericsnowcurrently

Crash report

What happened?

I haven't seen this before, but I don't think it's new. Rather, I suspect it's a very uncommon race in interpreter finalization. It might also be specific to ARM (or more likely there).

The same crash happened in two different tests in test_interpreters.test_stress:

  • test_create_many_threaded
  • test_many_threads_running_interp_in_other_interp

From https://buildbot.python.org/#/builders/234/builds/6611 run on the "aarch64 Fedora Stable Clang 3.x" buildbot worker:

test_create_many_threaded (test.test_interpreters.test_stress.StressTests.test_create_many_threaded) ... Warning -- Uncaught thread exception: InterpreterError
Exception in thread Thread-45 (task):
RuntimeError: Failed to import encodings module

During handling of the above exception, another exception occurred:

interpreters.InterpreterError: sub-interpreter creation failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang/build/Lib/threading.py", line 1041, in _bootstrap_inner
    self.run()
    ~~~~~~~~^^
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang/build/Lib/threading.py", line 992, in run
    self._target(*self._args, **self._kwargs)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang/build/Lib/test/test_interpreters/test_stress.py", line 30, in task
    interp = interpreters.create()
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang/build/Lib/test/support/interpreters/__init__.py", line 76, in create
    id = _interpreters.create(reqrefs=True)
interpreters.InterpreterError: interpreter creation failed
ok
test_many_threads_running_interp_in_other_interp (test.test_interpreters.test_stress.StressTests.test_many_threads_running_interp_in_other_interp) ... ok

----------------------------------------------------------------------
Ran 152 tests in 33.434s
OK (skipped=5)
python: Objects/typeobject.c:296: void managed_static_type_state_clear(PyInterpreterState *, PyTypeObject *, int, int): Assertion `!_PyRuntime.types.managed_static.types[full_index].interp_count' failed.

On that same buildbot run:

test_many_threads_running_interp_in_other_interp (test.test_interpreters.test_stress.StressTests.test_many_threads_running_interp_in_other_interp) ... Warning -- Uncaught thread exception: InterpreterError
Exception in thread Thread-239 (run):
RuntimeError: Failed to import encodings module

During handling of the above exception, another exception occurred:

interpreters.InterpreterError: sub-interpreter creation failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang/build/Lib/threading.py", line 1041, in _bootstrap_inner
    self.run()
    ~~~~~~~~^^
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang/build/Lib/threading.py", line 992, in run
    self._target(*self._args, **self._kwargs)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang/build/Lib/test/test_interpreters/test_stress.py", line 47, in run
    interp = interpreters.create()
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-aarch64.clang/build/Lib/test/support/interpreters/__init__.py", line 76, in create
    id = _interpreters.create(reqrefs=True)
interpreters.InterpreterError: interpreter creation failed
ok

----------------------------------------------------------------------
Ran 152 tests in 32.930s

OK (skipped=5)
python: Objects/typeobject.c:296: void managed_static_type_state_clear(PyInterpreterState *, PyTypeObject *, int, int): Assertion `!_PyRuntime.types.managed_static.types[full_index].interp_count' failed.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Other

Output from running 'python -VV' on the command line:

No response

Activity

added
interpreter-core(Objects, Python, Grammar, and Parser dirs)
type-crashA hard crash of the interpreter, possibly with a core dump
3.14new features, bugs and security fixes
on Nov 21, 2024
ericsnowcurrently

ericsnowcurrently commented on Nov 21, 2024

@ericsnowcurrently
MemberAuthor

This may affect 3.13 too, but we'd need to double-check.

changed the title [-]Crash in test_interpreters.test_stress (test_create_many_threaded)[/-] [+]test_interpreters.test_stress Crashes in managed_static_type_clear()[/+] on Nov 21, 2024
freakboy3742

freakboy3742 commented on Mar 20, 2025

@freakboy3742
Contributor

@ericsnowcurrently Some more data for you - this is a semi-regular failure on the iOS buildbot. There have been 6 examples of in the last 2 months:

This may affect 3.13 too, but we'd need to double-check.

I can confirm that I've also seen it on 3.13 (though less frequently, probably because there are less builds):

changed the title [-]test_interpreters.test_stress Crashes in managed_static_type_clear()[/-] [+]test_interpreters.test_stress Crashes in managed_static_type_state_clear()[/+] on Apr 17, 2025
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

    3.14new features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)topic-subinterpreterstype-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @freakboy3742@ericsnowcurrently

        Issue actions

          test_interpreters.test_stress Crashes in managed_static_type_state_clear() · Issue #127108 · python/cpython