Skip to content

[Bug]: Telegram gateway SIGSEGV / exit 139 during httpx.ReadError reconnect loop on Raspberry Pi aarch64 #25666

@rab1dd0g

Description

@rab1dd0g

Bug Description

A Telegram Hermes gateway repeatedly crashes with SIGSEGV on Raspberry Pi aarch64.

This affects more than one Hermes profile on the same host. I have two separate profile gateways, each with its own Telegram bot token and systemd service. Both profiles have crashed with status=11/SEGV, so this appears to be in the shared gateway/runtime path rather than a profile-specific data issue.

The crash was reproduced both:

  • under the systemd-managed Hermes gateway service
  • in foreground mode using hermes -p <profile> gateway run

During the foreground test, the last visible output before the process exited was repeated Telegram reconnect warnings:

WARNING gateway.platforms.telegram: [Telegram] Telegram network error, scheduling reconnect: httpx.ReadError:
WARNING gateway.platforms.telegram: [Telegram] Telegram network error (attempt 1/10), reconnecting in 5s. Error: httpx.ReadError:

The foreground capture then ended with:

Script done on 2026-05-14 18:36:05+10:00 [COMMAND_EXIT_CODE="139"]

Exit code 139 is consistent with SIGSEGV.

The Pi itself appeared healthy during the crashes: no disk pressure, no RAM pressure, no swap use, normal temperature, and no throttle/undervoltage flags.

Steps to Reproduce

  1. Configure two separate Hermes profiles with Telegram gateway enabled.
  2. Run each profile as a system-level gateway service.
  3. Leave the gateways running while Telegram polling/reconnects occur.
  4. Observe intermittent gateway crashes in journald with:
Main process exited, code=killed, status=11/SEGV
  1. Stop one affected profile service and run that same profile in foreground mode:
sudo -u hermes -H bash -lc '
export PATH="/home/hermes/.local/bin:$PATH"
script -q -f /tmp/hermes-foreground-capture.log -c "hermes -p <profile> gateway run"
  1. Wait for Telegram reconnect warnings.

Observed foreground output before exit:

WARNING gateway.platforms.telegram: [Telegram] Telegram network error, scheduling reconnect: httpx.ReadError:
WARNING gateway.platforms.telegram: [Telegram] Telegram network error (attempt 1/10), reconnecting in 5s. Error: httpx.ReadError:
  1. The foreground script capture ended with:
COMMAND_EXIT_CODE="139"

Expected Behavior

Telegram network errors such as httpx.ReadError should be handled by reconnect/retry logic without terminating the gateway process.

The gateway should either recover the Telegram polling connection or log a recoverable platform error while keeping the gateway process alive.

Actual Behavior

The gateway process intermittently exits with SIGSEGV.

Systemd examples from the current boot:

May 14 07:01:47 hermes-pi systemd[1]: hermes-gateway-<profile-b>.service: Main process exited, code=killed, status=11/SEGV
May 14 07:02:28 hermes-pi systemd[1]: hermes-gateway-<profile-a>.service: Main process exited, code=killed, status=11/SEGV
May 14 07:06:32 hermes-pi systemd[1]: hermes-gateway-<profile-b>.service: Main process exited, code=killed, status=11/SEGV
May 14 07:46:41 hermes-pi systemd[1]: hermes-gateway-<profile-a>.service: Main process exited, code=killed, status=11/SEGV
May 14 11:15:38 hermes-pi systemd[1]: hermes-gateway-<profile-a>.service: Main process exited, code=killed, status=11/SEGV
May 14 11:40:49 hermes-pi systemd[1]: hermes-gateway-<profile-a>.service: Main process exited, code=killed, status=11/SEGV
May 14 14:03:27 hermes-pi systemd[1]: hermes-gateway-<profile-a>.service: Main process exited, code=killed, status=11/SEGV
May 14 19:32:14 hermes-pi systemd[1]: hermes-gateway-<profile-b>.service: Main process exited, code=killed, status=11/SEGV

Foreground reproduction:

WARNING gateway.platforms.telegram: [Telegram] Telegram network error, scheduling reconnect: httpx.ReadError:
WARNING gateway.platforms.telegram: [Telegram] Telegram network error (attempt 1/10), reconnecting in 5s. Error: httpx.ReadError:
WARNING gateway.platforms.telegram: [Telegram] Telegram network error, scheduling reconnect: httpx.ReadError:
WARNING gateway.platforms.telegram: [Telegram] Telegram network error (attempt 1/10), reconnecting in 5s. Error: httpx.ReadError:
WARNING gateway.platforms.telegram: [Telegram] Telegram network error, scheduling reconnect: httpx.ReadError:
WARNING gateway.platforms.telegram: [Telegram] Telegram network error (attempt 1/10), reconnecting in 5s. Error: httpx.ReadError:

Script done on 2026-05-14 18:36:05+10:00 [COMMAND_EXIT_CODE="139"]

No Python traceback was captured before the SIGSEGV.

Affected Component

Gateway (Telegram/Discord/Slack/WhatsApp)

Messaging Platform (if gateway-related)

Telegram

Debug Report

Report       https://paste.rs/VKOym
agent.log    https://paste.rs/0ICjW
gateway.log  https://paste.rs/H4V2g

Operating System

Raspberry Pi OS Lite 64-bit / Debian 13 trixie, Linux 6.12.75+rpt-rpi-v8 aarch64

Python Version

3.11.15

Hermes Version

Hermes Agent v0.13.0 (2026.5.7), commit dd0923b

Additional Logs / Traceback (optional)

Foreground capture from `script`:

WARNING gateway.platforms.telegram: [Telegram] Telegram network error, scheduling reconnect: httpx.ReadError:
WARNING gateway.platforms.telegram: [Telegram] Telegram network error (attempt 1/10), reconnecting in 5s. Error: httpx.ReadError:
WARNING gateway.platforms.telegram: [Telegram] Telegram network error, scheduling reconnect: httpx.ReadError:
WARNING gateway.platforms.telegram: [Telegram] Telegram network error (attempt 1/10), reconnecting in 5s. Error: httpx.ReadError:
WARNING gateway.platforms.telegram: [Telegram] Telegram network error, scheduling reconnect: httpx.ReadError:
WARNING gateway.platforms.telegram: [Telegram] Telegram network error (attempt 1/10), reconnecting in 5s. Error: httpx.ReadError:

Script done on 2026-05-14 18:36:05+10:00 [COMMAND_EXIT_CODE="139"]

Service Python/runtime:

executable: /home/hermes/.hermes/hermes-agent/venv/bin/python
python: 3.11.15 (main, May 10 2026, 19:28:24) [Clang 22.1.3]
platform: Linux-6.12.75+rpt-rpi-v8-aarch64-with-glibc2.41
sqlite3: 3.50.4
numpy: 2.4.3
pydantic_core: 2.41.5
onnxruntime: 1.26.0
tokenizers: 0.23.1

No Python traceback was captured before the process exited.

Root Cause Analysis (optional)

Unknown.

Based on the evidence, this appears to be a native/runtime crash in the shared Telegram gateway path rather than a normal Python exception:

  • no Python traceback appeared before the crashes
  • systemd reported status=11/SEGV
  • foreground mode exited with COMMAND_EXIT_CODE="139"
  • repeated Telegram httpx.ReadError reconnect warnings appeared immediately before the foreground exit
  • more than one Hermes profile on the same host was affected

Possible areas to investigate:

  • Telegram polling/reconnect handling
  • python-telegram-bot / httpx reconnect path
  • gateway background scheduler/cron interaction with Telegram reconnects
  • native dependencies loaded in the gateway process

Proposed Fix (optional)

No response

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/gatewayGateway runner, session dispatch, deliveryplatform/telegramTelegram bot adaptersweeper:implemented-on-mainSweeper: behavior already present on current maintype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions