test suite: add workaround for Debian Trixie Python interpreter bug

The Debian Trixie Python interpreter (v3.13.5) crashes on exit after executing
scripts that write signed transactions (`mmgen-txsign` and `mmgen-txsend`) for
certain tests in the test suite.

This bug is unlikely to be observed under normal usage and in any case won’t
prevent users from signing and sending transactions.

Nonetheless, users running Debian Trixie may wish to compile Python from source
just to be safe and use the locally compiled Python to run MMGen Wallet.

For instructions on how to do this, see the ‘Build Python from Source’ wiki page.
This commit is contained in:
The MMGen Project 2026-08-22 18:34:46 +00:00
commit d5f6398da4
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 19 additions and 7 deletions

View file

@ -480,6 +480,11 @@ def have_sudo(*, silent=False):
except:
return False
def distro_codename():
if os.path.exists('/etc/os-release'):
with open('/etc/os-release') as fh:
return next(line for line in fh if line.startswith('VERSION_CODENAME=')).rstrip().split('=', 1)[1]
def in_nix_environment():
for path in os.getenv('PATH').split(':'):
if path.startswith('/nix/store/'):

View file

@ -20,10 +20,10 @@
test.cmdtest_d.base: Base class for the cmdtest.py test suite
"""
import os
import sys, os
from mmgen.cfg import gc
from mmgen.util import msg
from mmgen.util import msg, distro_codename
from mmgen.color import gray, purple, yellow
from ..include.common import write_to_file, read_from_file, imsg
@ -68,6 +68,10 @@ class CmdTestBase:
self.spawn_env['MMGEN_TEST_SUITE_ENABLE_COLOR'] = '1' if self.color else ''
else:
self.spawn_env = {} # placeholder
self.has_segfault_on_exit_bug = (
self.coin in ('btc', 'bch')
and distro_codename() == 'trixie'
and sys.version_info[:2] == (3, 13))
def get_altcoin_pfx(self, coin, cashaddr=True):
coin = coin.lower()

View file

@ -776,7 +776,8 @@ class CmdTestMain(CmdTestBase, CmdTestShared):
add_output_args = ['hexdata:' + 'ee' * self.proto.max_op_return_data_len])
def txsign1(self, *args, **kwargs):
return self.txsign(*args, **kwargs)
t = self.txsign(*args, **kwargs)
return 'ok' if self.has_segfault_on_exit_bug else t
def txbump1(self, txfile, prepend_args=[], seed_args=[]):
if not self.proto.cap('rbf'):
@ -815,7 +816,7 @@ class CmdTestMain(CmdTestBase, CmdTestShared):
def txsend1(self, sigfile, extra_opts=[]):
t = self.spawn('mmgen-txsend', extra_opts + ['-d', self.tmpdir, sigfile], no_passthru_opts=['coin'])
self.txsend_ui_common(t, view='t', add_comment='')
return t
return 'ok' if self.has_segfault_on_exit_bug else t
def txdo1(self, addrfile, wallet):
t = self.txcreate_common(sources=['1'], ss_args=[wallet])
@ -974,7 +975,7 @@ class CmdTestMain(CmdTestBase, CmdTestShared):
t.view_tx('n')
t.passphrase(wcls.desc, self.cfgs[cnum]['wpasswd'])
self.txsign_end(t, cnum)
return t
return 'ok' if self.has_segfault_on_exit_bug else t # this segfaults only with --bech32
def export_mnemonic2(self, wf):
return self.export_mnemonic(wf)
@ -1128,4 +1129,5 @@ class CmdTestMain(CmdTestBase, CmdTestShared):
tweaks = ['confirm_non_mmgen'])
def txsign6(self, wf, txf):
return self.txsign5(wf, txf, bad_vsize=False, add_opts=['--vsize-adj=1.08'])
t = self.txsign5(wf, txf, bad_vsize=False, add_opts=['--vsize-adj=1.08'])
return 'ok' if self.has_segfault_on_exit_bug else t

View file

@ -526,7 +526,8 @@ class CmdTestSwap(CmdTestSwapMethods, CmdTestRegtest, CmdTestAutosignThreaded):
return self._data_tx_sign()
def data_tx1_send(self):
return self._data_tx_send()
t = self._data_tx_send()
return 'ok' if self.has_segfault_on_exit_bug else t
def data_tx1_chk(self):
return self._data_tx_chk(sample1.encode().hex())