Frequent RPi5 segfaults on startup

I’ve recently migrated my HA instance from a very old NUC to a RPi5, and I’ve found that the HA core is segfaulting on startup most of the time. Once it starts, it’s generally fine, but it’s just a problem on startup.

Things I’ve tried:

  • Changing the PSU and power cable.
  • Checking for underpower events with vcgencmd get_throttled. (There are none.)
  • Checking the fan. (It’s working.)
  • Changing the SD card.
  • Reflashing the SD card / changing the OS (same issue happens on Bookworm, Trixie and HAOS 16.3).
  • Changing the network device. (Happens when both connected to wifi and ethernet.)
  • Running in debug mode
  • Running in safe mode

Every time I get this in the HA log:

s6-rc: info: service legacy-services successfully started
2025-11-30 15:07:58.717 WARNING (Recorder) [homeassistant.components.recorder.util] The system could not validate that the sqlite3 database at //config/home-assistant_v2.db was shutdown cleanly
2025-11-30 15:07:58.781 WARNING (Recorder) [homeassistant.components.recorder.util] Ended unfinished session (id=167 from 2025-11-30 15:06:32.327707)
[15:08:03] INFO: Home Assistant Core finish process exit code 256
[15:08:03] INFO: Home Assistant Core finish process received signal 11

And a home-assistant.log.fault with the following contents:

Fatal Python error: Segmentation fault

Thread 0x0000007f88bfe3b8 (most recent call first):
  File "/usr/local/lib/python3.13/site-packages/pycares/__init__.py", line 348 in _run_safe_shutdown_loop
  File "/usr/local/lib/python3.13/threading.py", line 994 in run
  File "/usr/local/lib/python3.13/threading.py", line 1043 in _bootstrap_inner
  File "/usr/local/lib/python3.13/threading.py", line 1014 in _bootstrap

Thread 0x0000007f8a3fe3b8 (most recent call first):
  File "/usr/local/lib/python3.13/threading.py", line 359 in wait
  File "/usr/local/lib/python3.13/concurrent/futures/_base.py", line 451 in result
  File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 665 in _wait_startup_or_shutdown
  File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 765 in _run
  File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 677 in run
  File "/usr/local/lib/python3.13/threading.py", line 1043 in _bootstrap_inner
  File "/usr/local/lib/python3.13/threading.py", line 1014 in _bootstrap

Current thread 0x0000007f8ff7e3b8 (most recent call first):
  File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1321 in create_module
  File "<frozen importlib._bootstrap>", line 813 in module_from_spec
  File "<frozen importlib._bootstrap>", line 921 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
  File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1329 in exec_module
  File "<frozen importlib._bootstrap>", line 935 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
  File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1329 in exec_module
  File "<frozen importlib._bootstrap>", line 935 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
  File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1329 in exec_module
  File "<frozen importlib._bootstrap>", line 935 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
  File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1329 in exec_module
  File "<frozen importlib._bootstrap>", line 935 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
  File "/usr/local/lib/python3.13/site-packages/av/filter/__init__.py", line 1 in <module>
  File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1027 in exec_module
  File "<frozen importlib._bootstrap>", line 935 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
  File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1310 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
  File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1329 in exec_module
  File "<frozen importlib._bootstrap>", line 935 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
  File "/usr/local/lib/python3.13/site-packages/av/__init__.py", line 10 in <module>
  File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1027 in exec_module
  File "<frozen importlib._bootstrap>", line 935 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
  File "/usr/src/homeassistant/homeassistant/components/stream/__init__.py", line 238 in set_pyav_logging
  File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 59 in run
  File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 93 in _worker
  File "/usr/local/lib/python3.13/threading.py", line 994 in run
  File "/usr/local/lib/python3.13/threading.py", line 1043 in _bootstrap_inner
  File "/usr/local/lib/python3.13/threading.py", line 1014 in _bootstrap

Thread 0x0000007f90b723b8 (most recent call first):
  File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 90 in _worker
  File "/usr/local/lib/python3.13/threading.py", line 994 in run
  File "/usr/local/lib/python3.13/threading.py", line 1043 in _bootstrap_inner
  File "/usr/local/lib/python3.13/threading.py", line 1014 in _bootstrap

Thread 0x0000007f90c763b8 (most recent call first):
  File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 90 in _worker
  File "/usr/local/lib/python3.13/threading.py", line 994 in run
  File "/usr/local/lib/python3.13/threading.py", line 1043 in _bootstrap_inner
  File "/usr/local/lib/python3.13/threading.py", line 1014 in _bootstrap

Thread 0x0000007f90d7a3b8 (most recent call first):
  File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 90 in _worker
  File "/usr/local/lib/python3.13/threading.py", line 994 in run
  File "/usr/local/lib/python3.13/threading.py", line 1043 in _bootstrap_inner
  File "/usr/local/lib/python3.13/threading.py", line 1014 in _bootstrap

Thread 0x0000007f90e7e3b8 (most recent call first):
  File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 90 in _worker
  File "/usr/local/lib/python3.13/threading.py", line 994 in run
  File "/usr/local/lib/python3.13/threading.py", line 1043 in _bootstrap_inner
  File "/usr/local/lib/python3.13/threading.py", line 1014 in _bootstrap

Thread 0x0000007f9177e3b8 (most recent call first):
  File "<frozen importlib._bootstrap_external>", line 1218 in get_data
  File "<frozen importlib._bootstrap_external>", line 1119 in get_code
  File "<frozen importlib._bootstrap_external>", line 1023 in exec_module
  File "<frozen importlib._bootstrap>", line 935 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
  File "<frozen importlib._bootstrap>", line 1387 in _gcd_import
  File "/usr/local/lib/python3.13/importlib/__init__.py", line 88 in import_module
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 201 in protected_loop_func
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1066 in _get_component
  File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 59 in run
  File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 93 in _worker
  File "/usr/local/lib/python3.13/threading.py", line 994 in run
  File "/usr/local/lib/python3.13/threading.py", line 1043 in _bootstrap_inner
  File "/usr/local/lib/python3.13/threading.py", line 1014 in _bootstrap

Thread 0x0000007f925ea3b8 (most recent call first):
  File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 90 in _worker
  File "/usr/local/lib/python3.13/threading.py", line 994 in run
  File "/usr/local/lib/python3.13/threading.py", line 1043 in _bootstrap_inner
  File "/usr/local/lib/python3.13/threading.py", line 1014 in _bootstrap

Thread 0x0000007f926ee3b8 (most recent call first):
  File "/usr/local/lib/python3.13/logging/handlers.py", line 1539 in dequeue
  File "/usr/local/lib/python3.13/logging/handlers.py", line 1593 in _monitor
  File "/usr/local/lib/python3.13/threading.py", line 994 in run
  File "/usr/local/lib/python3.13/threading.py", line 1043 in _bootstrap_inner
  File "/usr/local/lib/python3.13/threading.py", line 1014 in _bootstrap

Thread 0x0000007f9ee44020 (most recent call first):
  File "/usr/local/lib/python3.13/selectors.py", line 452 in select
  File "/usr/local/lib/python3.13/asyncio/base_events.py", line 2012 in _run_once
  File "/usr/local/lib/python3.13/asyncio/base_events.py", line 683 in run_forever
  File "/usr/local/lib/python3.13/asyncio/base_events.py", line 712 in run_until_complete
  File "/usr/src/homeassistant/homeassistant/runner.py", line 289 in run
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 215 in main
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 229 in <module>
  File "<frozen runpy>", line 88 in _run_code
  File "<frozen runpy>", line 198 in _run_module_as_main

Extension modules: _cffi_backend, ciso8601, yaml._yaml, propcache._helpers_c, ulid_transform._ulid_impl, multidict._multidict, yarl._quoting_c, markupsafe._speedups, _brotli, backports.zstd._zstd, aiohttp._http_writer, aiohttp._http_parser, aiohttp._websocket.mask, aiohttp._websocket.reader_c, frozenlist._frozenlist, annotatedyaml.reference, annotatedyaml.constructors, _awscrt, charset_normalizer.md, simplejson._speedups, requests.packages.charset_normalizer.md, requests.packages.chardet.md, regex._regex, dbus_fast.signature, dbus_fast._private.marshaller, dbus_fast.message, dbus_fast.service, dbus_fast._private.address, dbus_fast.unpack, dbus_fast.message_bus, dbus_fast._private.unmarshaller, dbus_fast.aio.message_reader, habluetooth.models, habluetooth.advertisement_tracker, bluetooth_data_tools.gap, bluetooth_data_tools._time_impl, bluetooth_data_tools._utils_impl, bluetooth_data_tools.utils, habluetooth.scanner, habluetooth.channels.bluez, habluetooth.manager, habluetooth.base_scanner, zeroconf._utils.time, zeroconf._dns, zeroconf._protocol.outgoing, zeroconf._protocol.incoming, zeroconf._cache, zeroconf._record_update, zeroconf._history, zeroconf._updates, zeroconf._services, zeroconf._utils.ipaddress, zeroconf._services.info, zeroconf._services.registry, zeroconf._handlers.answers, zeroconf._handlers.multicast_outgoing_queue, zeroconf._handlers.query_handler, zeroconf._handlers.record_manager, zeroconf._listener, zeroconf._services.browser, sqlalchemy.cyextension.collections, sqlalchemy.cyextension.immutabledict, sqlalchemy.cyextension.processors, sqlalchemy.cyextension.resultproxy, sqlalchemy.cyextension.util, greenlet._greenlet, fnv_hash_fast._fnv_impl, PIL._imaging, isal.igzip_lib, isal.isal_zlib, numpy._core._multiarray_umath, numpy.linalg._umath_linalg, cached_ipaddress.ipaddress, audioop._audioop, av._core, av.logging, av.bytesource, av.buffer, av.audio.format, av.enum, av.error, av.utils, av.option, av.descriptor, av.container.pyio, av.dictionary, av.format, av.stream, av.container.streams, av.sidedata.motionvectors, av.sidedata.sidedata, av.opaque, av.packet, av.container.input, av.container.output, av.container.core, av.codec.context, av.video.format, av.video.reformatter, av.plane, av.video.plane, av.video.frame, av.video.stream, av.codec.codec, av.frame, av.audio.layout, av.audio.plane, av.audio.frame, av.audio.stream, av.audio.codeccontext, av.filter.filter, av.filter.graph, av.filter.context, av.filter.link (total: 114)

Odd thing: when it’s upstairs and the HDMI port is attached to the TV, it segfaults maybe half the time. When it’s downstairs and headless, it segfaults every time.

The only thing I can think of that is not on the list is resetting the bootloader on the pi.I believe there is an option in the pi imager to create boot recovery sd.

Perhaps a firmware update is needed?

https://www.raspberrypi.com/documentation/computers/os.html

Hi,
You’ve done pretty much every thing I’ve done (and have been using RPi since the original composite video version) so…

  • The RPi5 is more powerful, and the “official” RPi foundation PSU has a semi-standard mode to signal to the PMIC and supply extra 5V current above the usual USB-C spec. You don’t mention the PSU type, so I’d suggest a “RPI Trading” one. This is usually only an issue with lots of USB kit and/or a big SSD.
  • In desktop mode, there can occasionally be glitches with HDMI switching that restart the (new) Wayland display manager. The X11 version was worse, but HAOS shouldn’t care about a text console - but try no HDMI and only network.
    I found a cheap HDMI switch could freak out the older firmware, but not recently.
  • Flash a new SD card with the lastest desktop RPiOS and use it for a bit.
    Two reasons:
    • Any hardware instability might be more noticeable with a full OS
    • RPiOS will update the RPi5 firmware (run updates a few times).

Beyond that, I’d be looking at a GitHub bug against HAOS, or another RPi5.

My CM5 upgrade to a Yellow has been rock solid, and desktop RPi5 with a SSD HAT is also very usable.

If this helps, :heart: this post!

Is your database corrupt?

The thing that bugs me is that this isn’t a random RPi segfault. It’s perfectly reproducible - it always happens when homeassistant.components.stream.set_pyav_logging runs import av.

And if I remove default_config from the config file, no problem at all. Container stays up. If I then run:

# docker container exec -it homeassistant sh
/config # python3
Python 3.13.9 (main, Oct 15 2025, 21:30:44) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import av
Segmentation fault (core dumped)

So I’m beginning to suspect libav.

pip install -U av in the container and the problem is solved. homeassistant/core on github already has the latest version in requirements so I guess I just got unlucky with version numbers.

Not every RasPi bug is caused by cosmic rays…