Package: ledger
Version: 3.3.2-1+b4
Severity: normal

Dear Maintainer,

please find a script below to reproduce a segmentation fault when
calling ledger convert:

```
#!/bin/sh

set -e

ledger --version

cd /tmp
rm -rf ledger-segfault && mkdir ledger-segfault
cd ledger-segfault

# create three example files (1 ledger, 2 csvs to be imported):
cat << EOF > test.dat
tag CSV
tag Imported
tag reference_id
    assert value =~ /^[*]{8}[0-9]{19}/

2025/11/15 Order 12345
    Assets:Accounts Receivable              EUR 1025
    Income:Sales
EOF

cat << EOF > final1.csv
date,description,total,amount,reference_id
2025-11-29,,EUR 25.0,EUR 25.0,********6521949711467142203
EOF

cat << EOF > final2.csv
date,description,total,amount,reference_id
2026-03-03,Order 12345,EUR 100.0,EUR 100.0,********9581361030270551453
EOF

set -x

# call ledger convert for the final1.csv (SUCCESS):
ledger convert final1.csv --input-date-format "%Y-%m-%d" --invert --account 
"Assets:Bank One" --rich-data --file test.dat --now 2026-03-09

# append ledger convert output of final1.csv to ledger (SUCCESS):
ledger convert final1.csv --input-date-format "%Y-%m-%d" --invert --account 
"Assets:Bank One" --rich-data --file test.dat --now 2026-03-09 >> test.dat

# call ledger convert for the final2.csv (SEGFAULT):
ledger convert final2.csv --input-date-format "%Y-%m-%d" --invert --account 
"Assets:Bank One" --rich-data --file test.dat --now 2026-03-09
```

Running the script through strace gives me this:

```
[...]
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 319633
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=319633, si_uid=1000, 
si_status=0, si_utime=0, si_stime=0} ---
rt_sigreturn({mask=[]})                 = 319633
wait4(-1, 0x7ffdd799f06c, WNOHANG, NULL) = -1 ECHILD (No child processes)
dup2(11, 1)                             = 1
close(11)                               = 0
write(2, "+ ", 2+ )                       = 2
write(2, "ledger", 6ledger)                   = 6
write(2, " convert", 8 convert)                 = 8
write(2, " final2.csv", 11 final2.csv)             = 11
write(2, " --input-date-format", 20 --input-date-format)    = 20
write(2, " %Y-%m-%d", 9 %Y-%m-%d)                = 9
write(2, " --invert", 9 --invert)                = 9
write(2, " --account", 10 --account)              = 10
write(2, " Assets:Bank One", 16 Assets:Bank One)        = 16
write(2, " --rich-data", 12 --rich-data)            = 12
write(2, " --file", 7 --file)                  = 7
write(2, " test.dat", 9 test.dat)                = 9
write(2, " --now", 6 --now)                   = 6
write(2, " 2026-03-09", 11 2026-03-09)             = 11
write(2, "\n", 1
)                       = 1
rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], NULL, 8) = 0
vfork()                                 = 319634
rt_sigprocmask(SIG_SETMASK, [], ~[KILL STOP RTMIN RT_1], 8) = 0
wait4(-1, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGSEGV}], 0, NULL) = 319634
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=319634, si_uid=1000, 
si_status=SIGSEGV, si_utime=0, si_stime=0} ---
rt_sigreturn({mask=[]})                 = 319634
write(2, "Segmentation fault\n", 19Segmentation fault
)    = 19
0x7ffdd799f06c, WNOHANG, NULL) = -1 ECHILD (No child processes)
exit_group(139)                         = ?
+++ exited with 139 +++
```

which doesn't tell me much.

Commenting out the regex tag assertion for reference_id in test.dat
solves the problem, so I _assume_ it has something to do with it.

Might need forwarding upstream, if the issue persists on newer versions
of upstream. I haven't tested newer upstream versions.

Thank you for looking into this and your work on the package!

-- System Information:
Debian Release: 13.3
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.12.73+deb13-amd64 (SMP w/2 CPU threads; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages ledger depends on:
ii  libboost-filesystem1.83.0                            1.83.0-4.2
ii  libboost-iostreams1.83.0                             1.83.0-4.2
ii  libboost-python1.83.0 [libboost-python1.83.0-py313]  1.83.0-4.2
ii  libc6                                                2.41-12+deb13u1
ii  libgcc-s1                                            14.2.0-19
ii  libgmp10                                             2:6.3.0+dfsg-3
ii  libmpfr6                                             4.2.2-1
ii  libpython3.13                                        3.13.5-2
ii  libstdc++6                                           14.2.0-19

ledger recommends no packages.

Versions of packages ledger suggests:
ii  elpa-ledger     4.0.0-2
ii  python3-ledger  3.3.2-1+b4

-- no debconf information

-- 
Alex
# No gods, no masters.
# 47A5 9C45 FA69 E651 25ED 0B98 9891 FC5D 3C3C 4426

Attachment: signature.asc
Description: PGP signature

Reply via email to