Skip to content

Intermittent test failure on iOS during test_interpreters stress test: RuntimeError: Failed to import encodings module #131485

Closed
@freakboy3742

Description

@freakboy3742

Bug report

Bug description:

We've seen intermittent failures on the iOS buildbot during the execution of the test_interpreters test:

...
test_create_many_sequential (test.test_interpreters.test_stress.StressTests.test_create_many_sequential) ... ok
test_create_many_threaded (test.test_interpreters.test_stress.StressTests.test_create_many_threaded) ... ok
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-1571 (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 "/Users/buildbot/Library/Developer/XCTestDevices/4F6EA510-4EA0-4706-8B1F-020FE958C08F/data/Containers/Bundle/Application/DBFDCCFF-85B7-4B66-9B7D-D1A7666166D0/iOSTestbed.app/python/lib/python3.14/threading.py", line 1054, in _bootstrap_inner
    self.run()    
    ~~~~~~~~^^  
  File "/Users/buildbot/Library/Developer/XCTestDevices/4F6EA510-4EA0-4706-8B1F-020FE958C08F/data/Containers/Bundle/Application/DBFDCCFF-85B7-4B66-9B7D-D1A7666166D0/iOSTestbed.app/python/lib/python3.14/threading.py", line 996, in run
    self._target(*self._args, **self._kwargs)    
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
  File "/Users/buildbot/Library/Developer/XCTestDevices/4F6EA510-4EA0-4706-8B1F-020FE958C08F/data/Containers/Bundle/Application/DBFDCCFF-85B7-4B66-9B7D-D1A7666166D0/iOSTestbed.app/python/lib/python3.14/test/test_interpreters/test_stress.py", line 47, in run
    interp = interpreters.create()  
  File "/Users/buildbot/Library/Developer/XCTestDevices/4F6EA510-4EA0-4706-8B1F-020FE958C08F/data/Containers/Bundle/Application/DBFDCCFF-85B7-4B66-9B7D-D1A7666166D0/iOSTestbed.app/python/lib/python3.14/test/support/interpreters/__init__.py", line 76, in create    
    id = _interpreters.create(reqrefs=True)
interpreters.InterpreterError: interpreter creation failed
ok

----------------------------------------------------------------------
Ran 152 tests in 7.483s
OK (skipped=14)
0:05:31 load avg: 4.70 [248/486/1] test_interpreters failed (env changed)

The test itself passes seems to pass; the failure that is reported is a change in environment. The test passes on a re-run.

There have been 6 examples of this in the last 2 months:

It has also been observed in 3.13

It's not clear to me if this is an iOS issue (falling apart under the stress), or an issue with the underlying subinterpreter setup that iOS is able to (intermittently) expose. The "Failed to import encodings module" is the bit that gives me pause - There's no diagnostics on why the import failed, but that sort of error would be consistent with a path not being fully configured. It clearly is configured (in the normal case at least), but I'm wondering if having multiple threads start simultaneously could be exposing a leak where one thread thinks something has been configured but another thread is still initialising.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Other

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixestopic-subinterpreterstype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions