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