GNOME Bugzilla – Bug 460232
advanced portfolio report fails
Last modified: 2018-06-29 21:44:04 UTC
Please describe the problem: In /usr/share/gnucash/guile-modules/gnucash/report/advanced-portfolio.scm: 539: 98 [table-add-stock-rows-internal (# # # # ...) #t] ... 294: 99 (let* (# # # # ...) (for-each # #) (set! use-txn #) ...) 468: 100* (if (or include-empty #) (let* # # ...) ...) 469: 101 (let* (# # # ...) (total-value # # ...) ...) ... 294: 102 (let* (# # # # ...) (for-each # #) (set! use-txn #) ...) 468: 103* (if (or include-empty #) (let* # # ...) ...) 539: 104 [table-add-stock-rows-internal (# # # # ...) #f] ... 294: 105 (let* (# # # # ...) (for-each # #) (set! use-txn #) ...) 334: 106* [for-each #<procedure #f (split)> (# # # #)] In unknown file: ?: 107* [#<procedure #f (split)> #<swig-pointer Split * 9a0e920>] In /usr/share/gnucash/guile-modules/gnucash/report/advanced-portfolio.scm: 338: 108* (let* ((parent #)) (if (gnc:timepair-le # to-date) (begin # # #))) 339: 109 (if (gnc:timepair-le # to-date) (begin # # #)) 340: 110 (begin (for-each # #) (set! basis-list #) (for-each # #)) 341: 111* [for-each #<procedure #f (s)> (# #)] In unknown file: ?: 112* [#<procedure #f (s)> #<swig-pointer Split * 9a0e9f8>] In /usr/share/gnucash/guile-modules/gnucash/report/advanced-portfolio.scm: 345: 113* (cond (# # # # ...) (# #)) 346: 114* (and (not (same-account? current #)) (not (or # #))) 346: 115* [not ... 346: 116* [same-account? #<swig-pointer Account * 992a5d0> ()] 197: 117 [string=? "4df81b26a12f370efd826818d78aa802" #<undefined>] /usr/share/gnucash/guile-modules/gnucash/report/advanced-portfolio.scm:197:5: In procedure string= in expression (string=? (gncAccountGetGUID a1) (gncAccountGetGUID a2)): /usr/share/gnucash/guile-modules/gnucash/report/advanced-portfolio.scm:197:5: Wrong type argument in position 2 (expecting string): #<undefined> Steps to reproduce: 1. view advanced portfolio report 2. 3. Actual results: Error in report Expected results: Report displayed Does this happen every time? Yes Other information:
Other "advanced portfolio" bugs (feel free to close this one as "duplicate" if they are in fact identical or a direct subset of this bug): bug#115267 bug#336240 bug#342245 bug#343245 bug#344566 bug#346062 @John: Do you think you could add a very simple gnucash example data file, together with instructions on how to reproduce this bug? That would help a lot. Thanks. @Chris: Could this be SWIGification issue, in that gncAccountGetGUID returns #<undefined> where it used to return an empty string?
- does not look like any of the bugs. - only happened when I upgraded to 2.2.0 - I could not reproduce the problem with a new account tree,although it always happens with my old one. I tried some basic tests that looked like mine - ie accounts 0 balance etc. I will keep looking.
(In reply to comment #1) > @Chris: Could this be SWIGification issue, in that gncAccountGetGUID returns > #<undefined> where it used to return an empty string? Indeed, during the swigification I changed from using a gwrapped macro that, if the Account pointer was NULL, used to return the string version of the special guid_null(), to a swig-wrapped function that would just return SCM_UNDEFINED. I don't think I'd necessarily consider that change to be a bug though. Instead it's the type of change that's likely to uncover bugs elsewhere. In this case, it looks like there might be a split with a null account. @John, please save off a copy of the datafile with which you can reproduce. Then run Check and Repair on a copy of that datafile, and re-run the report that was crashing, and report back what happens. Thanks.
Chris - I tried the check and repair - didn't fix the problem. I tracked the problem down to a single account though. 'stock' account type, and there is a transaction with a price of 1 and no other values other than the date. I can't seem to delete the transaction. Blank transaction does nothing. Remove splits - does nothing - there don't seem to be any. I can't add values to it. Edit date and it gets reset. There were some transactions - from 2001 - earlier in the register that seemed to have lost their transfer account. I changed them to 'opening balances' and it now works. It used to have an account: <split:account type="guid">00000000000000000000000000000000</split:account>
Is this bug still out there? what about: (define (same-account? a1 a2) (if (and a1 a2) (string=? (gncAccountGetGUID a1) (gncAccountGetGUID a2)) '() ) ) and the same for (same-split? ...) I think that would return a false if one of the two accounts is #undefined which would be technically correct, but I don't know what the impact would be on the report overall.
Actually I think my solution above is silly. Probably better to just do something like: (define (same-account? a1 a2) (equal? a1 a2) ) this works in other code I've done since swigification. Then, once we realise that its just equal? we can probably rip that function out all together and replace it with equal? not sure how it works with same-split? but will check. patch to come. BTW, although this is caused by a likely corrupted file, it seems like this kind of failure shouldn't happen. Am I right in that?
Here is a patch that I think will fix this bug. I *think* that equal? won't care what type the arguments are and will just work despite whatever highlighted the error in the OP's file.
Created attachment 97370 [details] [review] fix swig smob comparisons
This patch is included in a larger patch to Advanced Portfolio posted to gnucash-devel: https://lists.gnucash.org/pipermail/gnucash-devel/2007-December/021694.html thanks
this patch is committed as part of r16620
did I do this right? blocks 486922 and it's definitely "Confirmed"
branches/2.2@r16663. Thanks a lot!
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=460232. Please update any external references or bookmarks.