GnuCash
Contact   Instructions
Bug 797384 - Gnucash doesn't handle commodity prices with big numerator/denominator properly
Summary: Gnucash doesn't handle commodity prices with big numerator/denominator properly
Status: NEW
Alias: None
Product: GnuCash
Classification: Unclassified
Component: Currency and Commodity (show other bugs)
Version: 3.5
Hardware: PC Linux
: Normal normal
Target Milestone: ---
Assignee: core
QA Contact: core
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-01 09:43 EDT by lazarczyk.dawid
Modified: 2019-09-02 09:59 EDT (History)
4 users (show)

See Also:


Attachments
Stacktrace when trying to open Net Worth Linechart (2.30 KB, text/plain)
2019-09-01 09:43 EDT, lazarczyk.dawid
no flags Details

Description lazarczyk.dawid 2019-09-01 09:43:03 EDT
Created attachment 373379 [details]
Stacktrace when trying to open Net Worth Linechart

I use Finance::Quote to obtain stock prices. The prices that end up in the price database tend to be quite accurate. E.g.
bad_value = 268 + 5055320467865/8425534113108
This is a number that causes trouble in Gnucash:
* 'Net worth linechart' crashes with:

Throw to key `numerical-overflow' with args `("/" "Numerical overflow" #f #f)'
more details in an attachment.

* Net Assets field in 'Accounts' tab fails to show any value, it just shows:
Net Assets: zł
(zł is a polish currency)

Repro:
1. Add 1 unit of stock X
2. Set price of X in price editor to bad_value
3.1 Look at 'Accounts tab
OR
3.2 Open 'Net worth linechart' and set 'price source' to 'nearest in time' so that bad_value is used for calculations which results in a crash.
Comment 1 Christopher Lam 2019-09-02 00:20:53 EDT
Thank you for your bug report! This is likely to be bug 797233 which is fixed in 3.6 onwards. Please try a newer build.
Comment 2 lazarczyk.dawid 2019-09-02 05:04:15 EDT
I updated Gnucash to 3.6 but it still doesn't work.
Note that the bug happens only when price for X is set to bad_value in dollars (than it's converted to zł).
The current value of USD/PLN in my price database is 3.9823.
Comment 3 Christopher Lam 2019-09-02 05:26:57 EDT
The pricedb entry for 268 + 5055320467865/8425534113108 is unreasonably precise; best modify the entry to 268.60 instead. I don't think there's mechanism to scrub these numbers.
Comment 4 lazarczyk.dawid 2019-09-02 06:04:31 EDT
Well, that's what I end up doing but manual fixing is a lot of toil.
Also, that defeats the purpose of automatic price lookup by Finance::Quote.
IMHO it doesn't sound too good if GUI allows you to enter values which end up crashing the backend?

A possible workaround would be to change the precision of values looked up by Finance::Quote but I'm not aware of such option.
Comment 5 John Ralls 2019-09-02 09:59:53 EDT
Chris, regardless of the precision there's an unhandled overflow exception in GncNumeric. We need to address that, all exceptions must be handled by C++ because an unhandled exception calls exit().

The problem that got fixed was the creation of prices with max-precision fractions from Finance::Quote, but it's still conceivable that such a price could be created with a normal transaction, especially in crypto currencies or mutual funds with 10^-9 SCUs. In light of that perhaps the no-round multiplication in pricedb's convert_balance is unwise.

Note You need to log in before you can comment on or make changes to this bug.