Memory leak in sqlite3.Connection.load_extension()
未关闭
还没有人认领这个 Issue。
extension-modules
topic-sqlite3
type-bug
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
Bug description:
Public issue regarding the issue found by @sushi-gif. Here is a summary of the discussion:
The function sqlite3.Connection.load_extension() has a minor memory leak that occurs when SQLite throws an error while loading an extension (sqlite3_load_extension). According to SQLite specifications, the buffer of the error message must be freed manually after use. The attached PR fixes the issue.
Reproduction code:
import sqlite3
cx = sqlite3.connect(":memory:")
cx.enable_load_extension(True)
for _ in range(1000000):
try:
cx.load_extension("does_not_exist")
except sqlite3.Error:
pass
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
- gh-154110
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 sqlite3.Connection.load_extension() 的实现开始,跟踪其对 sqlite3_load_extension 的调用。使用提供的重复失败加载复现来检查错误路径,并验证报告的内存泄漏已修复,同时不改变扩展成功加载的行为。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python, sqlite
- 领域
- databases
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100