Skip to content

Python 3.15 nogil fails with segmentation error #1330

Description

@Tusenka

Thank you for the asyncpg!
I'm trying to use asyncpg with python 3.15t.
Got failure:
`
Fatal Python error: Segmentation fault

Thread 0x00007c94459fd6c0 [asyncio_0] (most recent call first):
File "/home/cas12/.local/share/uv/python/cpython-3.15.0b2+freethreaded-linux-x86_64-gnu/lib/python3.15t/concurrent/futures/thread.py", line 116 in _worker
File "/home/cas12/.local/share/uv/python/cpython-3.15.0b2+freethreaded-linux-x86_64-gnu/lib/python3.15t/threading.py", line 1160 in run
File "/home/cas12/.local/share/uv/python/cpython-3.15.0b2+freethreaded-linux-x86_64-gnu/lib/python3.15t/threading.py", line 1218 in _bootstrap_inner
File "/home/cas12/.local/share/uv/python/cpython-3.15.0b2+freethreaded-linux-x86_64-gnu/lib/python3.15t/threading.py", line 1180 in _bootstrap

Thread 0x00007c94461fe6c0 [OtelPeriodicExp] (most recent call first):
File "/home/cas12/.local/share/uv/python/cpython-3.15.0b2+freethreaded-linux-x86_64-gnu/lib/python3.15t/threading.py", line 367 in wait
File "/home/cas12/.local/share/uv/python/cpython-3.15.0b2+freethreaded-linux-x86_64-gnu/lib/python3.15t/threading.py", line 664 in wait
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/opentelemetry/sdk/metrics/_internal/export/init.py", line 520 in _ticker
File "/home/cas12/.local/share/uv/python/cpython-3.15.0b2+freethreaded-linux-x86_64-gnu/lib/python3.15t/threading.py", line 1160 in run
File "/home/cas12/.local/share/uv/python/cpython-3.15.0b2+freethreaded-linux-x86_64-gnu/lib/python3.15t/threading.py", line 1218 in _bootstrap_inner
File "/home/cas12/.local/share/uv/python/cpython-3.15.0b2+freethreaded-linux-x86_64-gnu/lib/python3.15t/threading.py", line 1180 in _bootstrap

Current thread 0x00007c944a0d5780 [python] (most recent call first):
File "/home/cas12/.local/share/uv/python/cpython-3.15.0b2+freethreaded-linux-x86_64-gnu/lib/python3.15t/asyncio/selector_events.py", line 1078 in write
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/asyncpg/connection.py", line 443 in _get_statement
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/asyncpg/connection.py", line 657 in _prepare
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/asyncpg/connection.py", line 638 in prepare
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 773 in _prepare
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 526 in _prepare_and_execute
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 196 in greenlet_spawn
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/sqlalchemy/ext/asyncio/session.py", line 758 in delete
File "/home/cas12/vscode/coffee_and_code/src/db/user_repository.py", line 1342 in delete_user
File "/home/cas12/vscode/coffee_and_code/src/service/user_service.py", line 102 in delete_user
File "/home/cas12/vscode/coffee_and_code/src/api/routers/admin.py", line 317 in delete_user
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/fastapi/routing.py", line 312 in run_endpoint_function
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/fastapi/routing.py", line 424 in app
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/fastapi/routing.py", line 105 in app
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/starlette/_exception_handler.py", line 42 in wrapped_app
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/fastapi/routing.py", line 119 in app
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/starlette/routing.py", line 290 in handle
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/starlette/routing.py", line 736 in app
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/starlette/routing.py", line 716 in call
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/fastapi/middleware/asyncexitstack.py", line 18 in call
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/starlette/_exception_handler.py", line 42 in wrapped_app
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/starlette/middleware/exceptions.py", line 63 in call
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/starlette/middleware/base.py", line 144 in coro
File "/home/cas12/.local/share/uv/python/cpython-3.15.0b2+freethreaded-linux-x86_64-gnu/lib/python3.15t/asyncio/events.py", line 94 in _run
File "/home/cas12/.local/share/uv/python/cpython-3.15.0b2+freethreaded-linux-x86_64-gnu/lib/python3.15t/asyncio/base_events.py", line 2066 in _run_once
File "/home/cas12/.local/share/uv/python/cpython-3.15.0b2+freethreaded-linux-x86_64-gnu/lib/python3.15t/asyncio/base_events.py", line 682 in run_forever
File "/home/cas12/.local/share/uv/python/cpython-3.15.0b2+freethreaded-linux-x86_64-gnu/lib/python3.15t/asyncio/base_events.py", line 711 in run_until_complete
File "/home/cas12/.local/share/uv/python/cpython-3.15.0b2+freethreaded-linux-x86_64-gnu/lib/python3.15t/asyncio/runners.py", line 127 in run
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/pytest_asyncio/plugin.py", line 905 in inner
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/_pytest/python.py", line 166 in pytest_pyfunc_call
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/pluggy/_callers.py", line 121 in _multicall
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/pluggy/_manager.py", line 120 in _hookexec
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/pluggy/_hooks.py", line 512 in call
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/_pytest/python.py", line 1720 in runtest
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/pytest_asyncio/plugin.py", line 569 in runtest
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/_pytest/runner.py", line 179 in pytest_runtest_call
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/pluggy/_callers.py", line 121 in _multicall
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/pluggy/_manager.py", line 120 in _hookexec
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/pluggy/_hooks.py", line 512 in call
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/_pytest/runner.py", line 245 in
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/_pytest/runner.py", line 353 in from_call
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/_pytest/runner.py", line 244 in call_and_report
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/_pytest/runner.py", line 137 in runtestprotocol
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/_pytest/runner.py", line 118 in pytest_runtest_protocol
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/pluggy/_callers.py", line 121 in _multicall
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/pluggy/_manager.py", line 120 in _hookexec
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/pluggy/_hooks.py", line 512 in call
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/_pytest/main.py", line 396 in pytest_runtestloop
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/pluggy/_callers.py", line 121 in _multicall
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/pluggy/_manager.py", line 120 in _hookexec
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/pluggy/_hooks.py", line 512 in call
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/_pytest/main.py", line 372 in _main
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/_pytest/main.py", line 318 in wrap_session
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/_pytest/main.py", line 365 in pytest_cmdline_main
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/pluggy/_callers.py", line 121 in _multicall
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/pluggy/_manager.py", line 120 in _hookexec
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/pluggy/_hooks.py", line 512 in call
File "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/_pytest/config/init.py", line 199 in main
File "/home/cas12/bin/pycharm-262.7581.27/plugins/python-ce/helpers/pycharm/_jb_pytest_runner.py", line 84 in

Current thread's C stack trace (most recent call first):
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python", at _Py_DumpStack+0x30 [0x4ae970]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python" [0x55d24b]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python" [0x55d0e6]
Binary file "/lib/x86_64-linux-gnu/libc.so.6", at +0x45f60 [0x7c9449e45f60]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python", at _PyCriticalSection_SuspendAll+0x7a [0x1addbba]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python", at PyEval_SaveThread+0x6e [0x1addb2e]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python" [0x1cb9a1e]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python" [0x1cb98b9]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python" [0x1cb9843]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python" [0x1a32e9e]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python", at _PyFunction_Vectorcall+0x380 [0x1a17cc6]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python", at PyObject_VectorcallMethod+0x12a [0x1a79cae]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/asyncpg/protocol/protocol.cpython-315t-x86_64-linux-gnu.so", at +0x33252 [0x7c944774f252]
**Binary file "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/asyncpg/protocol/protocol.cpython-315t-x86_64-**linux-gnu.so", at +0xa1ec3 [0x7c94477bdec3]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/asyncpg/protocol/protocol.cpython-315t-x86_64-linux-gnu.so", at +0xb0c33 [0x7c94477ccc33]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/asyncpg/protocol/protocol.cpython-315t-x86_64-linux-gnu.so", at +0x301c7 [0x7c944774c1c7]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/lib/python3.15t/site-packages/asyncpg/protocol/protocol.cpython-315t-x86_64-linux-gnu.so", at +0x4de48 [0x7c9447769e48]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python" [0x1db5732]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python" [0x1caca40]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python" [0x4b6f31]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python" [0x4b6d6e]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python" [0x4b7df0]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python" [0x4b7cc0]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python" [0x1b5de80]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python" [0x1a14cce]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python", at _PyFunction_Vectorcall+0x380 [0x1a17cc6]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python" [0x1afdbe6]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python" [0x1afd902]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python", at PyObject_Vectorcall+0x28b [0x1a3024b]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python" [0x1a2faef]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python", at _PyFunction_Vectorcall+0x380 [0x1a17cc6]
Binary file "/home/cas12/vscode/coffee_and_code/.venv/bin/python" [0x1afdbe6]

Extension modules: greenlet._greenlet, numpy._core._multiarray_umath, numpy.linalg._umath_linalg, _cffi_backend, cryptography.hazmat.bindings._rust, _brotli, psutil._psutil_linux, asyncpg.pgproto.pgproto, asyncpg.protocol.record, asyncpg.protocol.protocol, psycopg2._psycopg, cython.cimports.libc.math (total: 12)
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions