Bus Error from Mercurial on Raspberry Pi

Copyright © 2024 J. M. Spivey
Jump to navigation Jump to search

Some versions of Mercurial, specifically the one in Bookworm, embed a version of the zstd compression library that is buggy on ARM32. The problem is described and diagnosed in these places:

Mercurial does not use the system zstd library for reasons best known to the Mercurial maintainers. While we wait for a later version of the zstd library to be bundled with Mercurial, a solution is to disable zstd compression manually, using one of these methods:

  • Put options in /etc/mercurial/hgrc. We need
to disable zstd for storing, and
compressionengines=zlib, none
for transmission. Alternatively, it might be possible to set [storage] revlog.zstd.level in order to avoid the bug, which apparently manifests itself only at some compression levels: see https://github.com/RPi-Distro/repo/issues/179.
  • Forcibly remove the bundled library file. After installing Mercurial using Pip, this was found in /usr/local/lib/python3.9/dist-packages/mercurial/zstd.cpython-39-arm-linux-gnueabihf.so. This is the solution I adopted on spivey.oriel.

Disabling this form of compression will make any repos that rely on it unusable: Mercurial detects them by looking for a line saying revlog-compression-zstd in .hg/store/requires within the repository. I believe this feature is added only when the repository is created, and it can be removed after disabling zstd by recloning from another source, even one that has zstd enabled itself.

On spivey.oriel, I have a later Mercurial installed than the one that came with Bullseye, because repos exist that use other more recent features; but still it suffers from this zstd bug. The python3-zstd package that comes with Bullseye has zstd version 1.4.5, and system zstd is 1.4.8. The bug is fixed in 1.4.8 but maybe not in 1.4.5.

All this could be avoided by using 64-bit RPiOS, rather than the 32-bit version with a 64-bit kernel.