Caused by trying to set the account on the blank split. The blank split
was present because the method used to clear the split list for the
receiving transaction in gnc_float_txn_to_txn_swap_accounts only removed
splits that belong to the transaction, and the blank split doesn't.
Adds new function xaccTransClearSplits to do a more thorough job.
Also improve the documentation for xaccSplitDestroy to better explain when
a transaction will be destroyed if it empties the split list.
# Please enter the commit message for your
changes. Lines starting
- Balancing lots always involves splits in the same account. So
the relevant number to use in the calculations is the split
amount, not the split value.
- Additionally don't assume transactions are single-currency.
So if amounts change, recalculate the associated values
based on deduced exchange rates.
- Finally if the lot balancing resulted in a split to be broken up
into two splits use conservative calculations for the new
splits' values to avoid introducing imbalances due to
rounding errors.
For wrong value type when retrieving a value from the SQL results row.
Profiling showed that most of the SQL load time was spent in handling
these exceptions, and using std::optional instead produced a > 11x
speedup (10 seconds vs. 115 seconds) when loading a large file.
Add new test files that are written with the latest version of GnuCash.
Test loading them, saving to compressed files, loading those compressed
files and writing to an uncompressed file. At every stage check it matches
the canonical version.
The conditions being containing a split from a voided transaction.
Instead of trying to destroy zero-value splits (doomed to fail in
that instance and generally rude otherwise) just remove them from
the lot list.
==88804== 8 bytes in 1 blocks are definitely lost in loss record 12 of 479
==88804== at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==88804== by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==88804== by 0x10B5D8: get_random_string_without (test-stuff.c:312)
==88804== by 0x10B655: get_random_string (test-stuff.c:333)
==88804== by 0x10AA92: test_string_fcn (test-vendor.c:138)
==88804== by 0x10A76B: test_vendor (test-vendor.c:88)
==88804== by 0x10AD5A: main (test-vendor.c:246)
+ 3 more
==88779== 8 bytes in 1 blocks are definitely lost in loss record 9 of 461
==88779== at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==88779== by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==88779== by 0x10B871: get_random_string_without (test-stuff.c:312)
==88779== by 0x10B8EE: get_random_string (test-stuff.c:333)
==88779== by 0x10AB9F: test_string_fcn (test-job.c:157)
==88779== by 0x10A7B1: test_job (test-job.c:87)
==88779== by 0x10AFF3: main (test-job.c:262)
+ 3 more
==88366== 8 bytes in 1 blocks are definitely lost in loss record 11 of 474
==88366== at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==88366== by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==88366== by 0x10B7E9: get_random_string_without (test-stuff.c:312)
==88366== by 0x10B866: get_random_string (test-stuff.c:333)
==88366== by 0x10AB64: test_string_fcn (test-employee.c:140)
==88366== by 0x10A7C1: test_employee (test-employee.c:87)
==88366== by 0x10AF6B: main (test-employee.c:246)
+ 4 more
==88327== 8 bytes in 1 blocks are definitely lost in loss record 13 of 667
==88327== at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==88327== by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==88327== by 0x10B890: get_random_string_without (test-stuff.c:312)
==88327== by 0x10B90D: get_random_string (test-stuff.c:333)
==88327== by 0x10AC7A: test_string_fcn (test-customer.c:146)
==88327== by 0x10A82E: test_customer (test-customer.c:79)
==88327== by 0x10B012: main (test-customer.c:229)
+ 3 more
==88718== 8 bytes in 1 blocks are definitely lost in loss record 21 of 1,880
==88718== at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==88718== by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==88718== by 0x11D6B9: get_random_string_without (test-stuff.c:312)
==88718== by 0x11D736: get_random_string (test-stuff.c:333)
==88718== by 0x116A91: test_commodity() (test-commodities.cpp:60)
==88718== by 0x117355: main (test-commodities.cpp:196)
+ 5 more
==88262== 6 bytes in 1 blocks are definitely lost in loss record 5 of 2,117
==88262== at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==88262== by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==88262== by 0x10B043: get_random_string_without (test-stuff.c:312)
==88262== by 0x10B0C0: get_random_string (test-stuff.c:333)
==88262== by 0x10A6E0: test_string_fcn (test-address.c:79)
==88262== by 0x10A694: test_address (test-address.c:69)
==88262== by 0x10A7C5: main (test-address.c:94)
+ 7 more
Valgrind uses "still reachable" because of the call to exit()
==87185== 94 bytes in 1 blocks are still reachable in loss record 193 of 241
==87185== at 0x4843828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==87185== by 0x15C234: main (test-xml2-is-file.cpp:42)
==87185==
==66427== 128 bytes in 1 blocks are definitely lost in loss record 22 of 25
==66427== at 0x4843738: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==66427== by 0x49B85EF: g_realloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==66427== by 0x49D6EF1: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==66427== by 0x49D6F6F: g_string_sized_new (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==66427== by 0x499AB00: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==66427== by 0x499B2D8: g_build_filename (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==66427== by 0x10A498: main (test-userdata-dir-invalid-home.c:74)
==66427==
==68902== 8 bytes in 1 blocks are definitely lost in loss record 7 of 251
==68902== at 0x4843828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==68902== by 0x5225948: g_malloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==68902== by 0x5240ED2: g_strdup (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==68902== by 0x13135E: g_strdup_inline (gstrfuncs.h:321)
==68902== by 0x13135E: dom_tree_to_text(_xmlNode*) (sixtp-dom-parsers.cpp:500)
==68902== by 0x141758: test_bad_string() (test-string-converters.cpp:70)
==68902== by 0x1417D8: main (test-string-converters.cpp:82)
==68902==
==68902== 93 bytes in 5 blocks are definitely lost in loss record 199 of 251
==68902== at 0x4843828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==68902== by 0x5225948: g_malloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==68902== by 0x5240ED2: g_strdup (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==68902== by 0x13135E: g_strdup_inline (gstrfuncs.h:321)
==68902== by 0x13135E: dom_tree_to_text(_xmlNode*) (sixtp-dom-parsers.cpp:500)
==68902== by 0x14169B: test_string_converters() (test-string-converters.cpp:55)
==68902== by 0x1417D3: main (test-string-converters.cpp:81)
==68902==
==68902== 260 (120 direct, 140 indirect) bytes in 1 blocks are definitely lost in loss record 242 of 251
==68902== at 0x4843828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==68902== by 0x48D5B84: xmlNewNode (in /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.14)
==68902== by 0x133873: text_to_dom_tree(char const*, char const*) (sixtp-dom-generators.cpp:53)
==68902== by 0x141748: test_bad_string() (test-string-converters.cpp:68)
==68902== by 0x1417D8: main (test-string-converters.cpp:82)
==68902==
==68902== 1,353 (600 direct, 753 indirect) bytes in 5 blocks are definitely lost in loss record 248 of 251
==68902== at 0x4843828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==68902== by 0x48D5B84: xmlNewNode (in /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.14)
==68902== by 0x133873: text_to_dom_tree(char const*, char const*) (sixtp-dom-generators.cpp:53)
==68902== by 0x14168B: test_string_converters() (test-string-converters.cpp:54)
==68902== by 0x1417D3: main (test-string-converters.cpp:81)
==68902==
==91379== 19 bytes in 1 blocks are definitely lost in loss record 2 of 9
==91379== at 0x4843828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==91379== by 0x48D1948: g_malloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==91379== by 0x48ED5B0: g_strconcat (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==91379== by 0x48B845F: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==91379== by 0x48B869E: g_dir_make_tmp (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==91379== by 0x10935E: main (test-resolve-file-path.c:71)
==87254== 40 (24 direct, 16 indirect) bytes in 1 blocks are definitely lost in loss record 107 of 242
==87254== at 0x4843828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==87254== by 0x503B948: g_malloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==87254== by 0x502F909: g_list_prepend (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==87254== by 0x194E83: QofQueryCoreTest_construct_predicate_guid_Test::TestBody() (gtest-qofquerycore.cpp:94)
==67054== 320 bytes in 32 blocks are definitely lost in loss record 2,213 of 2,238
==67054== at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==67054== by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==67054== by 0x118AD8: get_random_transaction_with_currency (test-engine-stuff.cpp:1395)
==67054== by 0x119897: add_random_transactions_to_book (test-engine-stuff.cpp:1848)
==67054== by 0x115FE8: run_test() (test-lots.cpp:99)
==67054== by 0x1160BF: main (test-lots.cpp:135)
==67054==
g_assert() can be compiled out, so should not be used for tests
g_assert_true was removed
to fis https://bugs.gnucash.org/show_bug.cgi?id=792008 because
g_assert_true was introduced in glib-2.38 and at the time GnuCash required
only glib-2.26. GnuCash has required glib >= 2.40 since 8acbc41c6 so
g_assert_true can be restored.
Alas, poor yahoo_json. After months of valiant struggle to keep up
with Yahoo!'s moving their API around the Finance::Quote team has
abandoned it, replacing it with a screen saver. Those tend to be
unstable so use alphavantage for testing.
Using a "close" time of 16:00 is a nice idea except that we don't know
what timezone it is, so it's not terribly useful. Use neutral time
instead so that the date will be right in all timezones.
If the size of "buff" is not evenly divisible by "size" then this would
allocate off the end of the buffer. That's not currently the case but the
calculation shouldn't do this. Change it to check there's actually enough
space.
ACCT_TYPE_NONE is -1 but it should always be masked out by compat;
explicitly check for this instead of relying on that.
Add parenthesis to be clear that the default precedence is what's intended.
Return a gnc_numeric instead of allocations that every caller has to free.
This makes it easier to fix the use after free in the unit test function
equals_node_val_vs_split_internal() where the expression in the return
statement wants to use the allocated gnc_numeric.
The "source" parameter is checked once at the start before using strcmp()
but is then used later on in GncQuotesImpl::query_fq() with function calls
that can't handle null values.
81b9a02235 changed the behaviour of the
"success" variable that's used for the return value, so now the value is
being repeatedly overwritten instead of being combined with the result of
the next call.
Restore the original behaviour of setting success to false on failure.
==4031== Invalid read of size 8
==4031== at 0x4E58C09: gncVendorGetAddr (gncVendor.c:677)
==4031== by 0x10A7E3: test_vendor (test-vendor.c:97)
...
==4031== Address 0x7e0c4e8 is 168 bytes inside a block of size 232 free'd
==4031== at 0x484620F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==4031== by 0x51526C3: g_type_free_instance (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
==4031== by 0x4E58616: gncVendorFree (gncVendor.c:511)
==4031== by 0x4E58EFF: vendor_free (gncVendor.c:782)
==4031== by 0x4E8611E: qof_commit_edit_part2 (qofinstance.cpp:1034)
==4031== by 0x4E58F59: gncVendorCommitEdit (gncVendor.c:788)
==4031== by 0x4E584EF: gncVendorDestroy (gncVendor.c:483)
==4031== by 0x10A729: test_vendor (test-vendor.c:80)
...
==4031== Block was alloc'd at
==4031== at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==4031== by 0x5033550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==4031== by 0x5157CBC: g_type_create_instance (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
==4031== by 0x513F20F: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
==4031== by 0x51407B7: g_object_new_with_properties (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
==4031== by 0x5141560: g_object_new (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
==4031== by 0x4E583CF: gncVendorCreate (gncVendor.c:459)
==4031== by 0x10A6A5: test_vendor (test-vendor.c:74)
...
==4029== Invalid read of size 8
==4029== at 0x4E41F15: gncEmployeeGetAddr (gncEmployee.c:642)
==4029== by 0x10A8A5: test_employee (test-employee.c:97)
...
==4029== Address 0x7e0c208 is 152 bytes inside a block of size 248 free'd
==4029== at 0x484620F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==4029== by 0x51526C3: g_type_free_instance (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
==4029== by 0x4E418D5: gncEmployeeFree (gncEmployee.c:477)
==4029== by 0x4E42144: emp_free (gncEmployee.c:714)
==4029== by 0x4E8611E: qof_commit_edit_part2 (qofinstance.cpp:1034)
==4029== by 0x4E4219E: gncEmployeeCommitEdit (gncEmployee.c:721)
==4029== by 0x4E41823: gncEmployeeDestroy (gncEmployee.c:459)
==4029== by 0x10A77F: test_employee (test-employee.c:79)
...
==4029== Block was alloc'd at
==4029== at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==4029== by 0x5033550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==4029== by 0x5157CBC: g_type_create_instance (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
==4029== by 0x513F20F: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
==4029== by 0x51407B7: g_object_new_with_properties (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
==4029== by 0x5141560: g_object_new (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
==4029== by 0x4E416DA: gncEmployeeCreate (gncEmployee.c:434)
==4029== by 0x10A6FB: test_employee (test-employee.c:73)
...
==4028== Invalid read of size 8
==4028== at 0x4E3F641: gncCustomerGetAddr (gncCustomer.c:579)
==4028== by 0x10A8EE: test_customer (test-customer.c:90)
...
==4028== Address 0x7e861b8 is 168 bytes inside a block of size 272 free'd
==4028== at 0x484620F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==4028== by 0x51526C3: g_type_free_instance (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
==4028== by 0x4E3EDD6: gncCustomerFree (gncCustomer.c:368)
==4028== by 0x4E3F57B: cust_free (gncCustomer.c:551)
==4028== by 0x4E8611E: qof_commit_edit_part2 (qofinstance.cpp:1034)
==4028== by 0x4E3F5D5: gncCustomerCommitEdit (gncCustomer.c:557)
==4028== by 0x4E3EC89: gncCustomerDestroy (gncCustomer.c:338)
==4028== by 0x10A7EC: test_customer (test-customer.c:71)
...
==4028== Block was alloc'd at
==4028== at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==4028== by 0x5033550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==4028== by 0x5157CBC: g_type_create_instance (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
==4028== by 0x513F20F: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
==4028== by 0x51407B7: g_object_new_with_properties (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
==4028== by 0x5141560: g_object_new (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
==4028== by 0x4E3EB0D: gncCustomerCreate (gncCustomer.c:309)
==4028== by 0x10A768: test_customer (test-customer.c:66)
...
==4028== Invalid read of size 8
==4028== at 0x4E3F796: gncCustomerGetShipAddr (gncCustomer.c:633)
==4028== by 0x10A91D: test_customer (test-customer.c:91)
...
==4028== Address 0x7e86210 is 256 bytes inside a block of size 272 free'd
==4028== at 0x484620F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==4028== by 0x51526C3: g_type_free_instance (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
==4028== by 0x4E3EDD6: gncCustomerFree (gncCustomer.c:368)
==4028== by 0x4E3F57B: cust_free (gncCustomer.c:551)
==4028== by 0x4E8611E: qof_commit_edit_part2 (qofinstance.cpp:1034)
==4028== by 0x4E3F5D5: gncCustomerCommitEdit (gncCustomer.c:557)
==4028== by 0x4E3EC89: gncCustomerDestroy (gncCustomer.c:338)
==4028== by 0x10A7EC: test_customer (test-customer.c:71)
...
==4028== Block was alloc'd at
==4028== at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==4028== by 0x5033550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==4028== by 0x5157CBC: g_type_create_instance (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
==4028== by 0x513F20F: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
==4028== by 0x51407B7: g_object_new_with_properties (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
==4028== by 0x5141560: g_object_new (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
==4028== by 0x4E3EB0D: gncCustomerCreate (gncCustomer.c:309)
==4028== by 0x10A768: test_customer (test-customer.c:66)
...
==7520== Invalid read of size 8
==7520== at 0x4E36DCC: guid_copy (guid.cpp:123)
==7520== by 0x1E3E62: KvpValueImpl::duplicate(KvpValueImpl const&) (kvp-value.cpp:378)
==7520== by 0x1E31CC: KvpValueImpl::KvpValueImpl(KvpValueImpl const&) (kvp-value.cpp:36)
==7520== by 0x1FF6C3: KvpValueTest_Copy_Test::TestBody() (test-kvp-value.cpp:74)
...
==7520== Address 0x7e10f48 is 8 bytes inside a block of size 16 free'd
==7520== at 0x4846AFF: operator delete(void*, unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==7520== by 0x4E36D98: guid_free (guid.cpp:115)
==7520== by 0x1E3D04: void delete_visitor::operator()<_gncGuid*>(_gncGuid*&) (kvp-value.cpp:358)
...
==7520== Block was alloc'd at
==7520== at 0x4843FA3: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==7520== by 0x4E36D5C: guid_malloc (guid.cpp:105)
==7520== by 0x4E36DC3: guid_copy (guid.cpp:122)
==7520== by 0x4E36EB0: guid_new (guid.cpp:153)
==7520== by 0x1FF4DB: KvpValueTest_Copy_Test::TestBody() (test-kvp-value.cpp:68)
Report options need to be saved when they're different from the
defaults, book options need to be saved when their value changes
regardless of whether it's the default value. That's dirty. Implement
it.
The pointer passed to the gfec exception handler is
not valid after the exception handler ends
==382525== Invalid read of size 1
==382525== at 0x484B050: memcpy@GLIBC_2.2.5 (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==382525== by 0x531AB67: __printf_buffer_write (Xprintf_buffer_write.c:39)
==382525== by 0x5322CD4: __printf_buffer (vfprintf-process-arg.c:501)
==382525== by 0x53465F3: __vasprintf_internal (vasprintf.c:102)
==382525== by 0x499C8C1: g_vasprintf (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==382525== by 0x4969BE0: g_strdup_vprintf (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==382525== by 0x494B2F6: g_logv (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==382525== by 0x494B7A2: g_log (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==382525== by 0x4862862: func_op (gnc-exp-parser.c:342)
==382525== by 0x485D381: primary_exp (expression_parser.c:1222)
==382525== by 0x485CE0F: multiply_divide_op (expression_parser.c:1028)
==382525== by 0x485CC33: add_sub_op (expression_parser.c:968)
==382525== Address 0xad387ec is 764 bytes inside a block of size 766 free'd
==382525== at 0x484620F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==382525== by 0x4861D9B: gfec_apply (gfec.c:145)
==382525== by 0x4862813: func_op (gnc-exp-parser.c:339)
==382525== by 0x485D381: primary_exp (expression_parser.c:1222)
==382525== by 0x485CE0F: multiply_divide_op (expression_parser.c:1028)
==382525== by 0x485CC33: add_sub_op (expression_parser.c:968)
==382525== by 0x485C9DE: assignment_op (expression_parser.c:886)
==382525== by 0x485C101: parse_string (expression_parser.c:605)
==382525== by 0x4862F07: gnc_exp_parser_parse_separate_vars (gnc-exp-parser.c:535)
==382525== by 0x4862D60: gnc_exp_parser_parse (gnc-exp-parser.c:475)
==382525== by 0x10A963: run_parser_test (test-exp-parser.c:94)
==382525== by 0x10AB99: run_parser_tests (test-exp-parser.c:144)
==382525== Block was alloc'd at
==382525== at 0x4843738: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==382525== by 0x4A81473: scm_realloc (in /usr/lib/x86_64-linux-gnu/libguile-3.0.so.1.5.0)
==382525== by 0x4AEEF70: scm_to_utf8_stringn (in /usr/lib/x86_64-linux-gnu/libguile-3.0.so.1.5.0)
==382525== by 0x55AA71F: gnc_scm_to_utf8_string (gnc-guile-utils.c:42)
==382525== by 0x4861D4E: gfec_apply (gfec.c:136)
==382525== by 0x4862813: func_op (gnc-exp-parser.c:339)
==382525== by 0x485D381: primary_exp (expression_parser.c:1222)
==382525== by 0x485CE0F: multiply_divide_op (expression_parser.c:1028)
==382525== by 0x485CC33: add_sub_op (expression_parser.c:968)
==382525== by 0x485C9DE: assignment_op (expression_parser.c:886)
==382525== by 0x485C101: parse_string (expression_parser.c:605)
==382525== by 0x4862F07: gnc_exp_parser_parse_separate_vars (gnc-exp-parser.c:535)
Make counters explicitly integer type and adjust the kvp load and save functions
to recognize that and behave accordingly so that other range options like day
threshold aren't affected.
- Also, remove unnecessary "static" in gnucash-style.c
The second one in guid.cpp is UB:
libgnucash/engine/guid.cpp:137:5: warning: undefined behavior, source object type 'const gnc::GUID' is not TriviallyCopyable [bugprone-undefined-memory-manipulation]
memcpy (&target, &source, sizeof (GncGUID));
^
A TXN_TYPE_PAYMENT will have non-APAR splits; a TXN_TYPE_LINK will not
have non-APAR splits. This bug manifests as a regular TXN_TYPE_PAYMENT
transaction being later voided being incorrectly changed to
TXN_TYPE_LINK.
The scrubbing routines are transaction oriented. Instead of
xaccAccountTreeScrubImbalance calling xaccAccountScrubImbalance for
each descendant, refactor so that the transaction list is generated
only once. The scrubbing is faster and progress bar is more accurate.
Bug 798930 caused some counters to be saved as KVP double. If the
correct int64_t value isn't found when reading, or if a double is
encountered when loading the option dialog, get the double value
and cast it to int64_t.
It was failing to produce a correct representation for input with more than
14 digits after the decimal poin. Fixes Bug 798916. The bug was in
powten so this fix may corect other problems too. For example conversion
of GncNumeric back to a string also failed in certain circumsances.
==515314== Invalid read of size 1
==515314== at 0x484AD67: __strcmp_sse42 (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==515314== by 0x171D36: do_test_list_handler (unittest-support.c:181)
==515314== by 0x171DCE: test_list_handler (unittest-support.c:197)
==515314== by 0x51BD4C1: g_logv (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==515314== by 0x51BD7A2: g_log (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==515314== by 0x4D5D0D9: xaccSplitEqualCheckBal (Split.c:753)
==515314== by 0x4D5D841: xaccSplitEqual (Split.c:869)
==515314== by 0x4D647A5: xaccTransEqual (Transaction.c:981)
==515314== by 0x15C0E8: test_xaccTransEqual(Fixture*, void const*) (utest-Transaction.cpp:901)
...
==515314== Address 0x8725260 is 0 bytes inside a block of size 59 free'd
==515314== at 0x484620F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==515314== by 0x15BDB1: test_xaccTransEqual(Fixture*, void const*) (utest-Transaction.cpp:883)
...
==515314== Block was alloc'd at
==515314== at 0x4843828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==515314== by 0x5618677: __vasprintf_internal (vasprintf.c:116)
==515314== by 0x520E8C1: g_vasprintf (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==515314== by 0x51DBBE0: g_strdup_vprintf (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==515314== by 0x51DBC9C: g_strdup_printf (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==515314== by 0x15BBAC: test_xaccTransEqual(Fixture*, void const*) (utest-Transaction.cpp:879)
...
ok 78 /engine/Transaction/xaccTransEqual
Thanks, Valgrind:
==515314== Invalid read of size 8
==515314== at 0x4ED46F3: gncInvoiceRemoveEntries (gncInvoice.c:767)
==515314== by 0x142B35: teardown_with_invoice (utest-Invoice.c:274)
...
==515314== Address 0x8557b98 is 8 bytes inside a block of size 24 free'd
==515314== at 0x484620F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==515314== by 0x51B565D: g_list_remove (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==515314== by 0x4ED42EF: gncInvoiceRemoveEntry (gncInvoice.c:688)
==515314== by 0x4ED46A2: gncInvoiceRemoveEntries (gncInvoice.c:781)
==515314== by 0x142B35: teardown_with_invoice (utest-Invoice.c:274)
...
==515314== Block was alloc'd at
==515314== at 0x4843828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==515314== by 0x51BD948: g_malloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==515314== by 0x51B1CB9: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==515314== by 0x4ED4271: gncInvoiceAddEntry (gncInvoice.c:676)
==515314== by 0x142401: setup_with_invoice (utest-Invoice.c:142)
...
ok 57 /engine/gncInvoice/post trans - vendor bill
The test relies on a lot of external dependencies
- installed finance-quote-wrapper
- alpha vantage key
- network
- working remote server
Running ./bin/test-gnc-quotes from the command line
will still include online_wiggle
Pass a boost::filesystem's c_str() rv to the ofstream constructor to
keep libstdc++ from transcoding it back to UTF8 and creating a broken
name or failing to match the directory name. Implemented in
gnc-filepath-utils to avoid spreading the boost::filesystem dependency
throughout the code base.
See https://github.com/boostorg/filesystem/issues/181 for why other
approaches don't work.
When the commodity table is registered, the current book will get
a default table assigned. When later setting the table explicitly
using qof_book_set_data() the exisiting table gets overwritten and
is thus leaked.
There is no way of removing or freeing a currency table from a book,
so the best we can do here is to set our own table on the book before
calling gnc_commodity_table_register().
If a function that returns an allocated pointer is passed directly into
something that does not take ownership of the pointer, the allocation is
leaked. This can be fixed by assigning the pointer to a new variable
and freeing it after operation on the memory.
At least one user has managed to get it set on their book so even
though it was supposed to be unimplemented it got through somehow.
Restoring it allows books with it set to load.
- Renamed option to "Account Balance" to avoid confusion with running
total.
- Added helper function to ensure running balance and balance forward
are only shown when transaction are grouped by account and sorted as
in register. In that case column heading remains "Running Balance"
and balance forward is shown. Otherwwise column heading is renamed
"Account Balance" and balance forward is not shown.
- Also added missing code for Common Currency conversion.
Ensure that dialog resources stored in options are freed when the
dialog is destroyed.
The crash happened when a new dialog replaced the old one on the options
and the old one's destructors tried to access a dangling reference to
a GtkWidget.
Edit/Report Options
As a result of auto instead of auto& in a std::visit call which
resulted in a temporary option whose GncOwner* was destroyed before
we could use it.
The previous change of the delimiter between namespace and symbol
is needed in both overloads of GncQuoteImpl::query_fq.
Also log the query json string to ease future troubleshooting.
This fixes memory leaks that are only present in testing code.
Not very useful on itself, but it does make it easier to fix memory
leaks and other AddressSanitizer problems in actual gnucash code later.
These were not used outside a test.
And that test was not leak free, as a result of the functions not doing
what they are supposed to do when the current value is not of the type
that is expected. (NULL is returned, but the value is not replaced)
Boost process wchar_t conversion chokes if it's fed an empty string.
This would happen when the user had no alphavantage key. Separate
the process invocation to not present the empty value to boost process.
When securities are in the list, the rows look twice as high as though
there is a linefeed at the end. This is partly due to commit for bug
797501 which worked at the time but a change in pango 50.4 to do with
wrapping has highlighted this bug.
To fix this only wrap currencies with ltr bidi isolate characters in
gnc_print_amount_with_bidi_ltr_isolate
It's better to use the default std::pair implementation
- spotted by clang-tidy bugprone-suspicious-string-compare
- will always return false, because type is the same
Also,
- remove redundant "using GncItem ..."
- spotted by clang-tidy bugprone
- probably no visible effects because of uniqueness, and other checks
libgnucash/engine/gnc-optiondb.cpp:149:5: warning: this call will remove at most one item even when multiple items should be removed [bugprone-inaccurate-erase]
m_options.erase(std::remove_if(m_options.begin(), m_options.end(),
^
libgnucash/engine/gnc-optiondb.cpp:358:5: warning: the value returned by this function should be used [bugprone-unused-return-value]
std::remove_if(m_callbacks.begin(), m_callbacks.end(),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libgnucash/engine/gnc-optiondb.cpp:358:5: note: cast the expression to void to silence this warning
for certain reports.
Those reports being ones using complex options, apparently because
the callbacks weren't protected from Guile's garbage collector.
So replace the anyway ugly hack of a void* with a std::any wrapping
a class holding a std::unique_ptr with a custom deleter. The
constructor calls scm_gc_protect_object on the SCM containing the
callback and the custom deleter calls scm_gc_unprotect_object. The
copy constructor, required for std::any, makes a new std::unique_ptr
and calls scm_gc_protect_object again ensuring that the protect and
unprotect calls are symmetrical.
Meanwhile std::any hides the Guile dependency from all the classes
that don't need to know about it. The only ugliness is that there's
no good place to put a common implementation of SCNCallbackWrapper so it's
repeated in gnc-optiondb.i and dialog-options.cpp.
The code is was only used by the csv import assistant and forced
gtk as a dependency on gnc-imp-props-tx
Part has been moved to Account, other bits have
been moved to the importer code where they were
used.