Skip to content

3.15 JIT crash in starlette test suite, when brotli is installed #158072

Description

@mgorny

Crash report

What happened?

I've built Python 3.15 branch with --with-pydebug --enable-experimental-jit. Then:

git clone https://github.com/Kludex/starlette/
cd starlette
uv venv -p ~/cpython/python  # my build
uv pip install -e . pytest anyio httpx2 sniffio jinja2 typing-extensions python-multipart trio itsdangerous httpx opentelemetry-sdk pyyaml brotli
.venv/bin/pytest -s

The result is:

========================================================= test session starts =========================================================
platform linux -- Python 3.15.0rc2+dev, pytest-9.1.1, pluggy-1.6.0                                                                     
rootdir: /home/mgorny/starlette                                                                                                        
configfile: pyproject.toml                                                                                                             
plugins: anyio-4.15.1                                                                                                                  
collected 1275 items                                                                                                                  

tests/middleware/test_base.py .....x..............................x.........................13
.
tests/middleware/test_body_limit.py ....................................
tests/middleware/test_cors.py ....................................
tests/middleware/test_errors.py ............
tests/middleware/test_gzip.py ..................................................
tests/middleware/test_https_redirect.py ......
tests/middleware/test_middleware.py ..
tests/middleware/test_opentelemetry.py .......................................................
tests/middleware/test_session.py ...........................
tests/middleware/test_trusted_host.py ...................................................
tests/middleware/test_wsgi.py ..........
tests/test__utils.py ...............
tests/test_applications.py .......................................................
tests/test_authentication.py ...........
tests/test_background.py ........
tests/test_concurrency.py ......
tests/test_config.py ......
tests/test_convertors.py ................
tests/test_datastructures.py ....................................................
tests/test_endpoints.py ..............................
tests/test_exceptions.py .........................
tests/test_formparsers.py .............................................................................................................
.......
tests/test_requests.py ..s........................................s......................python: Python/optimizer_symbols.c:1099: _Py_u
op_sym_apply_predicate_narrowing: Assertion `_Py_uop_sym_is_const(ctx, subject_ref)' failed.
Fatal Python error: Aborted

Current thread 0x00007f3a5b95c6c0 [Thread-794 (run] (most recent call first):
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/trio/_core/_run.py", line 2406 in setup_runner
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/trio/_core/_run.py", line 2518 in run
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/anyio/_backends/_trio.py", line 1092 in run
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/anyio/_core/_eventloop.py", line 83 in run
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/anyio/from_thread.py", line 538 in run_blocking_portal
  File "/home/mgorny/cpython/Lib/threading.py", line 1160 in run
  File "/home/mgorny/cpython/Lib/threading.py", line 1218 in _bootstrap_inner
  File "/home/mgorny/cpython/Lib/threading.py", line 1180 in _bootstrap
Thread 0x00007f3a5c6696c0 [Trio thread 1] (most recent call first):
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/trio/_core/_thread_cache.py", line 211 in _work
  File "/home/mgorny/cpython/Lib/threading.py", line 1160 in run
  File "/home/mgorny/cpython/Lib/threading.py", line 1218 in _bootstrap_inner
  File "/home/mgorny/cpython/Lib/threading.py", line 1180 in _bootstrap

Thread 0x00007f3a588836c0 [Trio thread 0] (most recent call first):
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/trio/_core/_thread_cache.py", line 211 in _work
  File "/home/mgorny/cpython/Lib/threading.py", line 1160 in run
  File "/home/mgorny/cpython/Lib/threading.py", line 1218 in _bootstrap_inner
  File "/home/mgorny/cpython/Lib/threading.py", line 1180 in _bootstrap

Thread 0x00007f3a6169ebc0 [pytest] (most recent call first):
  File "/home/mgorny/cpython/Lib/threading.py", line 363 in wait
  File "/home/mgorny/cpython/Lib/concurrent/futures/_base.py", line 449 in result
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/anyio/from_thread.py", line 554 in start_blocking_portal
  File "/home/mgorny/cpython/Lib/contextlib.py", line 203 in __enter__
  File "/home/mgorny/starlette/starlette/testclient.py", line 435 in _portal_factory
  File "/home/mgorny/cpython/Lib/contextlib.py", line 203 in __enter__
  File "/home/mgorny/starlette/starlette/testclient.py", line 355 in handle_request
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/httpx2/_client.py", line 1076 in _send_single_request
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/httpx2/_client.py", line 1043 in _send_handling_redirects
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/httpx2/_client.py", line 1008 in _send_handling_auth
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/httpx2/_client.py", line 980 in send
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/httpx2/_client.py", line 797 in request
  File "/home/mgorny/starlette/starlette/testclient.py", line 463 in request
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/httpx2/_client.py", line 1113 in get
  File "/home/mgorny/starlette/tests/test_requests.py", line 470 in test_cookies_invalid
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/_pytest/python.py", line 167 in pytest_pyfunc_call
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/pluggy/_callers.py", line 121 in _multicall
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/pluggy/_hooks.py", line 512 in __call__
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/_pytest/python.py", line 1707 in runtest
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/_pytest/runner.py", line 184 in pytest_runtest_call
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/pluggy/_callers.py", line 121 in _multicall
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/pluggy/_hooks.py", line 512 in __call__
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/_pytest/runner.py", line 250 in <lambda>
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/_pytest/runner.py", line 361 in from_call
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/_pytest/runner.py", line 249 in call_and_report
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/_pytest/runner.py", line 139 in runtestprotocol
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/_pytest/runner.py", line 118 in pytest_runtest_protocol
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/pluggy/_callers.py", line 121 in _multicall
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/pluggy/_hooks.py", line 512 in __call__
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/_pytest/main.py", line 408 in pytest_runtestloop
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/pluggy/_callers.py", line 121 in _multicall
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/pluggy/_hooks.py", line 512 in __call__
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/_pytest/main.py", line 384 in _main
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/_pytest/main.py", line 330 in wrap_session
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/_pytest/main.py", line 377 in pytest_cmdline_main
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/pluggy/_callers.py", line 121 in _multicall
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/pluggy/_hooks.py", line 512 in __call__
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/_pytest/config/__init__.py", line 229 in _main
  File "/home/mgorny/starlette/.venv/lib/python3.15/site-packages/_pytest/config/__init__.py", line 253 in _console_main
  File "/home/mgorny/starlette/.venv/bin/pytest", line 10 in <module>

Current thread's C stack trace (most recent call first):
  Binary file "/home/mgorny/starlette/.venv/bin/python", at _Py_DumpStack+0x48 [0x56409f367c3d]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at +0x48d57a [0x56409f38457a]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at +0x48deb1 [0x56409f384eb1]
  Binary file "/usr/lib64/libc.so.6", at +0x3e270 [0x7f3a6143e270]
  Binary file "/usr/lib64/libc.so.6", at +0x9919c [0x7f3a6149919c]
  Binary file "/usr/lib64/libc.so.6", at gsignal+0x16 [0x7f3a6143e146]
  Binary file "/usr/lib64/libc.so.6", at abort+0x28 [0x7f3a61425520]
  Binary file "/usr/lib64/libc.so.6", at +0x2671c [0x7f3a6142671c]
  Binary file "/usr/lib64/libc.so.6", at __assert_fail+0xb5 [0x7f3a61436295]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at +0x4383b3 [0x56409f32f3b3]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at +0x435dea [0x56409f32cdea]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at +0x436857 [0x56409f32d857]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at +0x42661f [0x56409f31d61f]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at _PyOptimizer_Optimize+0xed [0x56409f31df45]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at +0x2a6e36 [0x56409f19de36]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at _PyEval_EvalFrameDefault+0x1d784 [0x56409f1c161c]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at +0x2cc279 [0x56409f1c3279]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at +0x2cc474 [0x56409f1c3474]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at _PyFunction_Vectorcall+0x58 [0x56409f04d3c9]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at +0x1580ca [0x56409f04f0ca]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at +0x1581b7 [0x56409f04f1b7]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at +0x1fe213 [0x56409f0f5213]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at +0x1fe27e [0x56409f0f527e]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at +0x1f7059 [0x56409f0ee059]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at _PyObject_MakeTpCall+0xd2 [0x56409f04d573]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at +0x1567a6 [0x56409f04d7a6]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at PyObject_Vectorcall+0x27 [0x56409f04d7fc]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at _Py_VectorCall_StackRefSteal+0x99 [0x56409f1a04be]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at _PyEval_EvalFrameDefault+0x88cd [0x56409f1ac765]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at +0x2cc279 [0x56409f1c3279]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at +0x2cc474 [0x56409f1c3474]
  Binary file "/home/mgorny/starlette/.venv/bin/python", at _PyFunction_Vectorcall+0x58 [0x56409f04d3c9]
  <truncated rest of calls>

Extension modules: _brotli, yaml._yaml, markupsafe._speedups (total: 3)

The package list includes all dependencies needed to run the test suite, plus the optional dependency on brotli that seems necessary to cause the crash. I wasn't able to reproduce it while running the crashing test alone.

I've been also able to reproduce with main:

Python 3.16.0a0 (heads/main:8293654, Sep 24 2026, 12:49:34) [GCC 16.2.0]

CPython versions tested on:

3.15, CPython main branch

Operating systems tested on:

Linux

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

Python 3.15.0rc2+dev (tags/v3.15.0rc2-90-gad3a06d:ad3a06d, Sep 24 2026, 12:42:31) [GCC 16.2.0]

Linked PRs

Activity

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.15pre-release feature fixes, bugs and security fixes3.16new features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)topic-JITtype-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions