Skip to content

Segfault when trying to add commodity to null-commodity #2057

@madroach

Description

@madroach

I tried to somehow emulate the D directives behaviour of hledger in ledger to configure a default commodity added to any commodityless amount. Doing so I triggered a segfault:

test.journal:

commodity €
    format 1.000,00 €

C 1 "" = 1 €

2021-01-01 Testtransaction
    blub        1000 €
    blab
(gdb) run -f test.journal balance
Starting program: /home/madroach/src/ledger/ledger -f test.journal balance
[New process 36632]

Thread 1 received signal SIGSEGV, Segmentation fault.
ledger::amount_t::in_place_unreduce (this=<optimized out>) at amount.cc:735
735         if (("h" == comm->symbol() || "m" == comm->symbol()) && commodity_t::time_colon_by_default) {
(gdb) print comm
$1 = (ledger::commodity_t *) 0x0
(gdb) bt
#0  ledger::amount_t::in_place_unreduce (this=<optimized out>) at amount.cc:735
#1  0x0000028ab228d087 in ledger::value_t::unreduced (this=<optimized out>) at value.h:476
#2  ledger::report_t::display_value (this=<optimized out>, val=<error reading variable: Unhandled dwarf expression opcode 0xa3>) at report.cc:513
#3  0x0000028ab225945d in ledger::format_accounts::mark_accounts (this=0x28b496f1a00, account=..., flat=<optimized out>) at output.cc:229
#4  0x0000028ab22592fd in ledger::format_accounts::mark_accounts (this=0x28b496f1a00, account=..., flat=<optimized out>) at output.cc:207
#5  0x0000028ab225974f in ledger::format_accounts::flush (this=0x28b496f1a00) at output.cc:251
#6  0x0000028ab22b42c0 in ledger::item_handler<ledger::account_t>::flush (this=0x7f7fffff7498) at chain.h:76
#7  ledger::pass_down_accounts<ledger::basic_accounts_iterator>::pass_down_accounts (this=<optimized out>, handler=..., iter=..., _pred=..., _context=...)
    at filters.h:1069
#8  0x0000028ab228c5e1 in ledger::(anonymous namespace)::accounts_flusher::operator() (this=0x7f7fffff7808) at report.cc:443
#9  0x0000028ab228b7cd in ledger::report_t::accounts_report (this=0x28b2a63e000, handler=...) at report.cc:482
#10 0x0000028ab22bb1ae in ledger::reporter<ledger::account_t, boost::shared_ptr<ledger::item_handler<ledger::account_t> >, &ledger::report_t::accounts_report>:
:operator() (this=0x28b496e0180, args=...) at report.h:1106
#11 0x0000028ab22baebe in boost::detail::function::function_obj_invoker1<ledger::reporter<ledger::account_t, boost::shared_ptr<ledger::item_handler<ledger::acc
ount_t> >, &ledger::report_t::accounts_report>, ledger::value_t, ledger::call_scope_t&>::invoke (
    function_obj_ptr=<error reading variable: Unhandled dwarf expression opcode 0xa3>, a0=...) at /usr/local/include/boost/function/function_template.hpp:137
#12 0x000002884f2ddc67 in boost::function1<ledger::value_t, ledger::call_scope_t&>::operator() (this=<optimized out>, a0=...)
    at /usr/local/include/boost/function/function_template.hpp:763
#13 ledger::global_scope_t::execute_command (this=<optimized out>, args=..., at_repl=<optimized out>) at global.cc:272
#14 0x000002884f2de9cf in ledger::global_scope_t::execute_command_wrapper (this=0x28b496e8000, args=..., at_repl=<optimized out>) at global.cc:282
#15 0x000002884f2d0ecc in main (argc=<optimized out>, argv=0x7f7fffff8348, envp=<optimized out>) at main.cc:130
(gdb)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions