Fix: Windows access violation during startup when loading comfy_api_nodes (pydantic-core GC issue)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
変更は comfy_api_nodes/apis/__init__.py と nodes.py を init_builtin_api_nodes() 内で行います。モデルのインポートとノードの読み込みを指定の通り gc.disable()/gc.enable() で囲みます。完了とは、ComfyUI が Windows で複数回の実行後にアクセス違反なく起動することを意味します。
索引モデルが issue の本文から書いたものです。
説明
Problem
On Windows, ComfyUI crashes at startup with Windows fatal exception: access violation while loading the built-in API nodes (comfy_api_nodes). The stack trace points to pydantic's schema generation, triggered during import of comfy_api_nodes/apis/__init__.py (a file with ~1000+ pydantic models).
Root cause
This is a known bug in pydantic-core on Windows: the cyclic garbage collector traverses pydantic-core's internal objects (validators/serializers) while they are still being constructed, corrupting refcounts and causing the access violation. Tracked in pydantic discussion #13839.
Fix
Disable the cyclic GC while constructing all pydantic models in apis/__init__.py and during the loading of built-in API nodes:
In comfy_api_nodes/apis/__init__.py (add at the top):
import gc as _gc
_gc_was_enabled = _gc.isenabled()
_gc.disable()
And at the very end of the file:
if _gc_was_enabled:
_gc.enable()
In nodes.py -> init_builtin_api_nodes():
import gc
gc_was_enabled = gc.isenabled()
gc.disable()
try:
for node_file in api_nodes_files:
if not await load_custom_node(node_file, module_parent="comfy_api_nodes"):
import_failed.append(os.path.basename(node_file))
finally:
if gc_was_enabled:
gc.enable()
Verification
Tested across 8 consecutive startup runs — all completed successfully with no access violations.
Environment
- Windows 11, Python 3.12.10
- pydantic 2.14.2, pydantic-core 2.50.2
- ComfyUI 0.42.5
- 主要言語
- Python
- スター
- 146k
- フォーク
- 17.4k
- 平均マージ
- 19時間 44分
- マージ済み PR(30日)
- 178
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Comfy-Org/ComfyUI のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
ROCm gfx1100: contiguous-k/v SDPA workaround is gfx1151-only, MiniMax H3 sampling 2.2x slower on RX 7900 XTX対応中かも @TwelveNights が 3 日前に担当しました。 オープンPotential Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Sub-quadratic attention is ~10x slower on long sequences on RDNA2 (gfx1030) because the key passed to bmm is non-contiguous対応中かも @KornienkoDev が 3 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
MoGe-3 output is nondeterministic on CUDA: sparse_pool3d_mean sums with float index_add_ (atomics)対応中かも @potoior が 9 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
Comfy-Org/ComfyUI#17498 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
TRELLIS.2 texture bake fails under --bf16-vae: BakeTextureFromVoxel 'Got unsupported ScalarType BFloat16'対応中かも @Shubham-Padkonde が 11 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
Comfy-Org/ComfyUI の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
OCA/account-invoicing#2529 ·
メンテナーはふだん 1 日以内に返信
-
area/ci
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
ImageGen generate-batch aborts valid JSONL jobs containing a Unicode line separator in poster textオープンbug imagen skills
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Email validation accepts a trailing newline対応中かも @marcello-pichini が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信