New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Floating point exception: 8 in ledger::amount_t::in_place_invert with R$,00000 in pricedb #1703

Closed
khass1 opened this Issue Jan 11, 2019 · 5 comments

Comments

Projects
None yet
3 participants
@khass1
Copy link

khass1 commented Jan 11, 2019

When I try running the following command ledger -f test.ledger r assets:investments:funds:BTGPacYieldDIFICP -V on the attached files I get the error "Floating point exception: 8".

It works when I use the argument“b” instead of “r” though. Is there any workaround for this?

Thanks

Archive.zip

@tbm

This comment has been minimized.

Copy link
Contributor

tbm commented Jan 11, 2019

Starting program: ledger -f test.ledger --price-db prices.db r assets:investments:funds:BTGPacYieldDIFICP -V
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGFPE, Arithmetic exception.
0x00007ffff6c8877a in __gmp_exception () from /usr/lib/x86_64-linux-gnu/libgmp.so.10
(gdb) where
#0  0x00007ffff6c8877a in __gmp_exception () from /usr/lib/x86_64-linux-gnu/libgmp.so.10
#1  0x00007ffff6c887ae in __gmp_divide_by_zero () from /usr/lib/x86_64-linux-gnu/libgmp.so.10
#2  0x00007ffff6ca52c5 in __gmpq_inv () from /usr/lib/x86_64-linux-gnu/libgmp.so.10
#3  0x00007ffff7937782 in ledger::amount_t::in_place_invert (this=0x7fffffffcfc0) at src/amount.cc:607
#4  0x00007ffff78f4937 in ledger::commodity_history_impl_t::map_prices(boost::function<void (boost::posix_time::ptime, ledger::amount_t const&)>, ledger::comm
odity_t const&, boost::posix_time::ptime const&, boost::posix_time::ptime const&, bool) (this=0x55555590d5d0, fn=..., source=..., moment=..., oldest=..., 
    bidirectionally=true) at src/history.cc:352
#5  0x00007ffff78f39ed in ledger::commodity_history_t::map_prices(boost::function<void (boost::posix_time::ptime, ledger::amount_t const&)>, ledger::commodity
_t const&, boost::posix_time::ptime const&, boost::posix_time::ptime const&, bool) (this=0x55555590d548, fn=..., source=..., moment=..., _oldest=..., 
    bidirectionally=true) at src/history.cc:162
#6  0x00007ffff792dc97 in ledger::commodity_t::map_prices(boost::function<void (boost::posix_time::ptime, ledger::amount_t const&)>, boost::posix_time::ptime 
const&, boost::posix_time::ptime const&, bool) (this=0x555555913390, fn=..., moment=..., _oldest=..., bidirectionally=true)
    at src/commodity.cc:88
#7  0x00007ffff77b2863 in ledger::changed_value_posts::output_intermediate_prices (this=0x555555f9a7d0, post=..., current=...)
    at src/filters.cc:788
#8  0x00007ffff77b1a53 in ledger::changed_value_posts::flush (this=0x555555f9a7d0) at src/filters.cc:636
#9  0x00007ffff774b66f in ledger::item_handler<ledger::post_t>::flush (this=0x555555f997b0) at src/chain.h:76
#10 0x00007ffff774b66f in ledger::item_handler<ledger::post_t>::flush (this=0x555555f99a10) at src/chain.h:76
#11 0x00007ffff774b66f in ledger::item_handler<ledger::post_t>::flush (this=0x7fffffffd9a0) at src/chain.h:76
#12 0x00007ffff77f2086 in ledger::pass_down_posts<ledger::journal_posts_iterator>::pass_down_posts (this=0x7fffffffd9a0, handler=..., iter=...)
    at src/filters.h:168
#13 0x00007ffff77d6810 in ledger::report_t::posts_report (this=0x55555590e6a0, handler=...) at src/report.cc:359
#14 0x00007ffff77fd994 in ledger::reporter<ledger::post_t, boost::shared_ptr<ledger::item_handler<ledger::post_t> >, &ledger::report_t::posts_report>::operato
r() (this=0x555555f93ac0, args=...) at src/report.h:1090
#15 0x00007ffff77fc090 in boost::detail::function::function_obj_invoker1<ledger::reporter<ledger::post_t, boost::shared_ptr<ledger::item_handler<ledger::post_
t> >, &ledger::report_t::posts_report>, ledger::value_t, ledger::call_scope_t&>::invoke (function_obj_ptr=..., a0=...)
    at /usr/include/boost/function/function_template.hpp:138
#16 0x000055555566f6ca in boost::function1<ledger::value_t, ledger::call_scope_t&>::operator() (this=0x7fffffffdba0, a0=...)
    at /usr/include/boost/function/function_template.hpp:771
#17 0x000055555565a148 in ledger::global_scope_t::execute_command (this=0x55555590a4f0, args=std::__cxx11::list = {...}, at_repl=false)
    at src/global.cc:261
#18 0x000055555565a38b in ledger::global_scope_t::execute_command_wrapper (this=0x55555590a4f0, args=std::__cxx11::list = {...}, at_repl=false)
    at src/global.cc:271
#19 0x0000555555638642 in main (argc=8, argv=0x7fffffffe7d8, envp=0x7fffffffe820) at src/main.cc:121

@tbm tbm changed the title Floating point exception: 8 when using register argument Floating point exception: 8 with reg and big pricedb, in ledger::amount_t::in_place_invert Jan 11, 2019

@tbm tbm added the bug label Jan 11, 2019

jwiegley added a commit that referenced this issue Jan 12, 2019

@jwiegley

This comment has been minimized.

Copy link
Member

jwiegley commented Jan 12, 2019

Looks like there should be a check before attempting to invert zero.

@tbm

This comment has been minimized.

Copy link
Contributor

tbm commented Jan 12, 2019

@khass1 this line is what causes the problem:

P 2018-10-31 MultifundosPlus R$,00000

@tbm tbm changed the title Floating point exception: 8 with reg and big pricedb, in ledger::amount_t::in_place_invert Floating point exception: 8 in ledger::amount_t::in_place_invert with R$,00000 in pricedb Jan 12, 2019

@khass1

This comment has been minimized.

Copy link

khass1 commented Jan 12, 2019

tbm added a commit that referenced this issue Jan 12, 2019

Add test case for issue #1703
Add a test case for issue #1703 which John Wiegley fixed in commit
56025cd ("Don't attempt to invert a value if it's already zero").
@tbm

This comment has been minimized.

Copy link
Contributor

tbm commented Jan 12, 2019

Fixed in 56025cd:

commit 40f84fa (HEAD -> next, origin/next, origin/HEAD)
Author: Martin Michlmayr tbm@cyrius.com
Date: Sat Jan 12 09:33:51 2019 -0200

Add test case for issue #1703

Add a test case for issue #1703 which John Wiegley fixed in commit
56025cde ("Don't attempt to invert a value if it's already zero").

commit 56025cd
Author: John Wiegley johnw@newartisans.com
Date: Fri Jan 11 16:25:02 2019 -0800

Don't attempt to invert a value if it's already zero (#1703)

@tbm tbm closed this Jan 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment