MagicStack / MagicStack/asyncpg

Python 3.15 nogil fails with segmentation error

未关闭
#1,330 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Python
星标
8.1k
派生
468
PR 合并指标
30 天内没有已合并 PR

描述

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)
`

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先,使用 Python 3.15t 和 asyncpg/connection.py 中所示的 asyncpg prepare 路径重现崩溃。检查 C 堆栈跟踪所涉及的 asyncpg 协议扩展,以及 delete/prepare 调用链;当所报告的操作在 free-threaded 解释器下不再导致 segmentation fault 时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
postgresql, python
领域
backend, databases
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
活跃
描述清晰度
需要澄清
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。