Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

FunctionManager reload can execute stale bytecode after same-size source edits

オープン 初心者向け
#688 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@jadelike-wine がすでに取り組んでいます。

2026年10月18日 から。

  • #689 @jadelike-wine による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
74/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

Issueでは utils/function_manager.py が特定され、reload_functions() の後に古い結果が表示される再現手順が示されています。ローダーを読み、説明されている再現手順を実行して失敗を確認してください。期待される結果は、リロードと新しく作成されたマネージャーが現在のソースを実行し、既存のソースエンコーディング、関数のフィルタリング、リロード時の削除動作も引き続き正常に機能することです。

索引モデルが issue の本文から書いたものです。

説明

FunctionManager.reload_functions() can continue executing a tool's old source after the file has been edited. The dynamic loader accepts a timestamp-based .pyc when the source has the same integer-second mtime and byte length. Two same-length saves within one second can therefore survive an explicit reload.

Reproduced against main a2ea4a263cebe9a7abd01ee3b5b0bf95698ed328 on Windows with Python 3.12.13:

import os
import tempfile
from pathlib import Path
from utils.function_manager import FunctionManager

with tempfile.TemporaryDirectory() as directory:
    tool = Path(directory) / "tool.py"
    tool.write_text("def value(): return 1\n", encoding="utf-8")
    os.utime(tool, (1700000000, 1700000000))
    manager = FunctionManager(directory)
    assert manager.call_function("value") == 1
    tool.write_text("def value(): return 2\n", encoding="utf-8")
    os.utime(tool, (1700000000, 1700000000))
    manager.reload_functions()
    assert manager.call_function("value") == 2  # fails: still returns 1

The fixed timestamp makes the cache collision deterministic; ordinary same-second edits can have the same effect. Creating a new manager also accepts a stale existing bytecode cache.

A focused fix is to execute compiled current source in the module namespace already prepared by module_from_spec, rather than reading the timestamp-based bytecode cache. Three tests against the real module give 2 failed, 1 passed on main and 3 passed with this change; the control checks source encoding, function filtering, and removing a tool on reload. No model/provider calls are involved.

This concerns source freshness, independently of the dataclass/module-registration issue #681 and closed PR #682. Searches for FunctionManager, reload, and bytecode found no matching report or PR. Prepared with Codex assistance; the reproduction and tests were run locally.

主要言語
Python
スター
34.6k
フォーク
4.3k
平均マージ
9時間 21分
マージ済み PR(30日)
1

環境構築

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

OpenBMB/ChatDev のほかの issue

OpenBMB/ChatDev の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。