Skip to content

Commit a1da86f

Browse files
jamietreclaude
andcommitted
Add faulthandler diagnostic for intermittent boot-time segfault
Not a fix — instrumentation. HA Core segfaults on roughly half of restarts, timing points at integration-loading during boot (before any LLM query), not the streaming-response CPython bug initially suspected (python/cpython#132413 needs an actual parsed chat response to trigger, which doesn't happen at boot). Raw container logs show no native crash traceback, meaning faulthandler wasn't enabled — so the actual crashing thread/frame is currently unknown, not confirmed to be gazetteer-matcher, kidde, or anything else specific. faulthandler.enable(all_threads=True) dumps every thread's Python stack to stderr on SIGSEGV/SIGABRT/etc, letting the next occurrence (expected soon, given the ~50% rate) actually identify what's running in each thread at crash time instead of inferring from log-line adjacency across concurrent import-executor threads, which isn't reliable when multiple integrations import concurrently. Deployed directly to the live instance (not released/tagged) at the user's request, for this investigation. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KBmTx4tChdcoCuCsJCjrLv
1 parent 03a96e9 commit a1da86f

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • custom_components/extended_openai_conversation

‎custom_components/extended_openai_conversation/__init__.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import faulthandler
56
import logging
67

78
from openai import AsyncClient
@@ -30,6 +31,14 @@
3031

3132
_LOGGER = logging.getLogger(__name__)
3233

34+
# Diagnostic: dump every thread's Python stack to stderr on a fatal signal
35+
# (SIGSEGV, SIGABRT, etc). Added to chase an intermittent (~50% of restarts)
36+
# segfault during boot, whose actual cause hasn't been pinpointed yet — see
37+
# commit message for context. Safe to leave enabled permanently (negligible
38+
# overhead, standard library, no behavior change) even after root-caused.
39+
if not faulthandler.is_enabled():
40+
faulthandler.enable(all_threads=True)
41+
3342
PLATFORMS = [Platform.AI_TASK, Platform.CONVERSATION]
3443
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
3544

0 commit comments

Comments
 (0)