Commit Graph

413 Commits

Author SHA1 Message Date
John Ralls
e22a57ad26 Merge John Ralls's 'asan' into stable. 2023-12-08 14:56:29 -08:00
John Ralls
d92d97aef6 Add Scheme coverage collection with option GUILE_COVERAGE.
This can be used with or without COVERAGE, though if without the
results will reflect only the Scheme code exercised by the tests.
2023-12-08 14:55:49 -08:00
Christopher Lam
d8ece96503 [gnc-engine-guile.cpp] plug runaway GSList* leak
The QofQuery param_list is a GSList of const char*. Every SCM Query
would typically leak the GSList. This change will store the params
into the string cache, and the cached string is passed onto the
QofQuery param.
2023-11-30 22:16:53 +08:00
Christopher Lam
3863d6e8dc [engine-common.i] AccountList* arg must be g_list_freed
when used by gnc_accounts_and_all_descendants
2023-11-27 21:05:06 +08:00
John Ralls
a3f14759ab Asan: Make leak and ODR violation reporting CMake options.
pass -DLEAKS=ON or -DODR=ON to enable these features. They have an
effect only with CMAKE_BUILD_TYPE=Asan and don't work on Apple because
Apple clang doesn't enable them.
2023-11-25 11:17:14 -08:00
John Ralls
e17ba3cc00 Fix UAF in xaccFreeSplit.
xaccSplitComputeCapGains creates gains_split pointers in both the Cap Gains Split and its Income split to the original split, but the original's gains_split pointer can point to only one of them, the Cap Gains split. When the original split is freed both the Cap Gains split's and its Income split need their gains_split pointers NULLed or when it's the Income split's turn to be freed it will try to deref the dangling pointer.
2023-11-02 12:58:55 -07:00
John Ralls
2234fa433e Add Asan build type that enables the Address and UB sanitizers.
Uses generator statements instead of CMAKE_<TYPE>_FLAGS_ASAN to support multiconfig generators like Xcode.
2023-11-02 12:58:46 -07:00
John Ralls
a389e0a32e Bug 799092 - GnuCash 5.4 leaves background process running on exit
Clear the schema_hash at app shutdown via gnc_prefs_remove_registered
and make that function available to the Python bindings so that
python programs can do so too.
2023-10-02 12:31:59 -07:00
Christopher Lam
550c43d13a Merge branch 'free-guid-string' into stable #1777 2023-09-20 07:29:16 +08:00
John Ralls
a49fd0bc09 [c++options] Correctly implement handling Fancy Date Format.
It's not a simple string.
2023-09-19 16:05:53 -07:00
Christopher Lam
8e21d3328f guid_to_string should be freed. 2023-09-19 20:31:11 +08:00
John Ralls
17ebb8a1d2 [simple-business-create.py] Overwrite an existing file instead of crashing. 2023-09-11 17:39:02 -07:00
Christopher Lam
7ce4198c20 rename string_to_gnc_numeric to gnc_numeric_from_string 2023-08-29 08:45:20 +08:00
Christopher Lam
75f6ee1817 [test-scm-engine] tests gnc-numeric-from-string 2023-08-29 08:30:52 +08:00
Geert Janssens
29b7a9099d Fix cmake warnings while searching for python
There is a new find module since cmake 3.12. Cmake 3.27 will start
emitting warnings if the old modules are still in use.

Current implementation supports both. As soon as we can bump our minimal
cmake version to 3.12, the old support code can be dropped as well.
2023-08-17 18:23:33 +02:00
Christopher Lam
867867da53 Merge Richard Cohen branch 'fix-leaks-in-tests' into stable #1713 2023-07-24 13:09:55 +08:00
John Ralls
50418527b0 Fix two typos. 2023-07-21 13:57:39 -07:00
John Ralls
2e76d2f43d Bug 799021 - Saved report renders default of gnc-register-list-option
save_scm_value was trying too hard to handle the different possible
types that Scheme can set options to and in the process converting
lists to single symobls (e.g. ('good 'ugly) became #{good ugly}#.
That not being one of the possible values it was ignored and the
default value was used.
2023-07-20 14:25:25 -07:00
Richard Cohen
e43982375c Valgrind: fix "definitely lost" memory in test - sqlite3test
==64824== 171 (88 direct, 83 indirect) bytes in 1 blocks are definitely lost in loss record 392 of 418
==64824==    at 0x4843FA3: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==64824==    by 0x528A935: qof_session_new (qofsession.cpp:148)
==64824==    by 0x141832: main (sqlite3test.c:34)
2023-07-19 10:21:30 +01:00
Christopher Lam
2a392633ed Bug 798991 - Incorrect Account Name Order in Transaction Report
gnc:string-locale<? uses glib instead of guile string compare
2023-07-11 08:41:09 +08:00
Richard Cohen
3c0b051ab0 Valgrind: fix "Mismatched free/delete" for gnc_print_time64, qof_print_date
... when called from guile e.g. test-transaction and lots of other tests

- gchar will also get the char* typemap, by typedef reduction

==119964== Mismatched free() / delete / delete []
==119964==    at 0x4847A1F: operator delete[](void*) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==119964==    by 0x669F3E4: _wrap_gnc_print_time64(scm_unused_struct*, scm_unused_struct*) (swig-engine.cpp:38533)
...

==119948== Mismatched free() / delete / delete []
==119948==    at 0x4847A1F: operator delete[](void*) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==119948==    by 0x6F6B431: _wrap_qof_print_date(scm_unused_struct*) (swig-engine.cpp:39124)
...
2023-06-20 10:20:44 +01:00
Richard Cohen
3957272ef0 Fix some typos in comments 2023-05-13 13:00:25 +01:00
Christopher Lam
56b75c3691 std::string cannot free() scm_to_utf8_string automatically 2023-04-04 23:24:22 +08:00
John Ralls
30cbf3074e Fix misplaced static variable decl.
Why this compiled is a mystery. Since empty wasn't captured it should
have raised an unused variable for the outside the lambda declaration
and an undeclared variable for the use inside. Only gcc 7 raised the
first error and nothing noticed the second.
2023-04-02 15:24:56 -07:00
John Ralls
d8a3e83189 Fix test breakage from account list reversal. 2023-04-01 18:14:31 -07:00
John Ralls
634b9f8744 Bug 798810 - Income Statement (multicolumn) - account sorting is...
'reversed' each time you restart.

Lists read from the front, vectors to the back, so reverse the
vector after loading it.

While we're at it reserve enough elements to hold the list.
2023-03-31 16:43:42 -07:00
Richard Cohen
9fa2a48fe1 Fix build on gcc-8 & 9.
See https://lists.gnucash.org/pipermail/gnucash-devel/2023-March/046617.html
2023-03-30 18:25:23 -07:00
John Ralls
b4b8431984 Bug 798778 - GnuCashquits abruptly when attempting to edit options…
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.
2023-03-16 17:50:06 -07:00
John Ralls
a44b3664e2 [c++options] Implement GncOptionGncOwnerValue class.
GncOwners aren't QofInstances and have limited lifetimes so an option
must hold its own, wrapped in std::unique_ptr for memory management.
2023-03-14 16:11:39 -07:00
Richard Cohen
329a2f7d42 Guard against some possible null pointer dereferences
Found by gcc 12 when compiling with "-O2 -Wnull-dereference"
2023-03-08 11:00:56 +00:00
John Ralls
1341511edb [c++options] Save an empty SCM string for nil or empty option values.
Avoids crash at reload due to unknown variable.
2023-03-06 15:36:23 -08:00
John Ralls
1eecb9f5c0 [c++ options] Fix locale dependency in test-gnc-option-scheme-output.
Created by using std::to_string() in GncOptionRangeValue::serialize.
It wraps sprintf that reads the locale. Use ostringstream instead.
2023-03-02 12:22:55 -08:00
Richard Cohen
be41bde58a Add missing MAKE_LINKS, and the local scm directory to %load-path
Before this change, "make check" would fail after
  rm -rf ${build}/share/guile/site/*/gnucash/
2023-02-28 11:51:23 +00:00
Richard Cohen
ec169e6e24 Fix some non-translatable typos 2023-02-27 11:32:12 +00:00
John Ralls
408b5ec216 [c++ options] Restore forward & backward compatibility, fix crash.
Store Number Range option values as a pair '(percentage . value) or '(pixels .
value) depending on the size of value as 4.x and earlier expect. When reading a
stored number range option handle the possibility that value is fixed
point (e.g. 50.0) as 4.x and earlier emit, avoiding a crash.
2023-02-25 16:25:36 -08:00
Richard Cohen
bddb4468fa Import GLIB2 as a target, and use it to simplify the CMakeLists 2023-02-21 12:59:42 +00:00
Richard Cohen
27fe72496e Remove unused ${GLIB_LIBS} ${GLIB_INCLUDE_DIRS}
They have been replaced by GLIB2_*
2023-02-21 12:50:38 +00:00
Richard Cohen
56d950598d [-Wunused-variable] - pretend to use
Looks like a SWIG bug, creating an extra variable that it doesn't use

bindings/python/gnucash_core.c: In function ‘_wrap_xaccAccountGetReconcileLastDate’:
bindings/python/gnucash_core.c:10096:10: warning: unused variable ‘secs20’ [-Wunused-variable]
10096 |   time64 secs20 ;
      |          ^~~~~~
bindings/python/gnucash_core.c: In function ‘_wrap_xaccAccountGetReconcilePostponeDate’:
bindings/python/gnucash_core.c:10298:10: warning: unused variable ‘secs20’ [-Wunused-variable]
10298 |   time64 secs20 ;
      |          ^~~~~~
bindings/python/gnucash_core.c: In function ‘_wrap_qof_query_date_predicate_get_date’:
bindings/python/gnucash_core.c:20237:10: warning: unused variable ‘secs20’ [-Wunused-variable]
20237 |   time64 secs20 ;
      |          ^~~~~~
2023-02-16 09:20:59 +00:00
Christopher Lam
4d977a947a [business-core] remove gnc:split->owner 2023-02-13 23:29:00 +08:00
Christopher Lam
d53f3e68d1 Merge branch 'maint' 2023-02-13 23:28:44 +08:00
Christopher Lam
4953cf94fa [reports] use gnc:make-split->owner with guardian
Instead of a gnc:split->owner, use gnc:make-split->owner instead which
generates a split->owner function with its own hashtable. This
function (and its hash table) will be garbage collected in due course,
triggering the gncOwnerFreeing of all owners.

This is a better approach than gnc:split->owner which maintains a
single hash table. It could be buggy: a report calls gnc:split->owner
to query a split, fails to reset its hashtable via #f; the split's
owner is assigned or modified, and the next call to gnc:split->owner
will return the incorrect cached owner.
2023-02-13 23:17:02 +08:00
John Ralls
732a005710 Merge Christoph Holtermann's 'python-log-access' into master. 2023-02-06 15:24:04 -08:00
Richard Cohen
78ec20515b Remove some unused variables - and the initialization
- checked that any side effects were irrelevant
2023-02-06 14:20:28 +00:00
Richard Cohen
ea2d3be217 Remove some unused variables with obviously no side effects 2023-02-06 14:19:22 +00:00
Christopher Lam
119356752f Merge branch 'maint' 2023-01-30 09:56:13 +08:00
luzpaz
67ab9e90d2 Fix some typos 2023-01-26 13:48:58 +01:00
John Ralls
f6919e60a7 Merge Richard Cohen's 'cleanup' into master. 2023-01-24 12:05:47 -08:00
Richard Cohen
d6ac56ce5f Re-enable -Waddress - gncInvoiceLookup etc. are now inline functions, not macros
- Remove outdated comments
2023-01-24 13:35:22 +00:00
Richard Cohen
1cec0cb3f3 Use internal extern "C" { ... } for C++
- removes warnings compiling swig engine
...
[ 10%] Generating swig-engine.cpp
.../libgnucash/engine/engine-helpers.h:31: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/gnc-date.h:83: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/qofquery.h:90: Warning 302: Identifier 'QofQuery' redefined (ignored),
.../libgnucash/engine/gnc-option.hpp:55: Warning 302: previous definition of 'QofQuery'.
.../libgnucash/engine/gnc-commodity.h:56: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/gncBusiness.h:40: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/gncEntry.h:37: Warning 313: Unrecognized extern type "C++".
2023-01-23 18:40:01 +00:00
Frank H. Ellenberger
d039e65aca Merge branch 'maint' 2023-01-22 11:25:44 +01:00