gnucash maint: Bug 798229 - GncDate::c_formats is being created and destroyed twice...

John Ralls jralls at code.gnucash.org
Tue Jul 6 15:04:13 EDT 2021


Updated	 via  https://github.com/Gnucash/gnucash/commit/ebf84fbf (commit)
	from  https://github.com/Gnucash/gnucash/commit/8d0bb719 (commit)



commit ebf84fbf8d987fe6bdeb3e75e7e4c05c66349fa3
Author: John Ralls <jralls at ceridwen.us>
Date:   Sun Jul 4 13:35:33 2021 -0700

    Bug 798229 - GncDate::c_formats is being created and destroyed twice...
    
    resulting in a double free crash on every exit.
    
    Exclude by name the obsolete pre-GnuCash 4 modules from being inspected
    so that they don't try to construct and destroy their static variables
    twice.

diff --git a/libgnucash/gnc-module/gnc-module.c b/libgnucash/gnc-module/gnc-module.c
index 65f2d23fe..638b1318b 100644
--- a/libgnucash/gnc-module/gnc-module.c
+++ b/libgnucash/gnc-module/gnc-module.c
@@ -140,7 +140,6 @@ gnc_module_system_search_dirs(void)
  * gnc_module_system_init
  * initialize the module system
  *************************************************************/
-
 void
 gnc_module_system_init(void)
 {
@@ -153,6 +152,45 @@ gnc_module_system_init(void)
     gnc_module_system_refresh();
 }
 
+static inline gboolean
+exclude_module (const char* module)
+{
+     /* These modules were converted to shared libraries and removed
+      * from GnuCash 4. Simply dlopening them will introduce duplicate
+      * symbols and cause unwanted initializations that may lead to a
+      * crash. See https://bugs.gnucash.org/show_bug.cgi?id=798229.
+      */
+   static const char* excluded_modules[] =
+    {
+        "libgncmod-app-utils",
+        "libgncmod-bi-import",
+        "libgncmod-csv-export",
+        "libgncmod-csv-import",
+        "libgncmod-customer-import",
+        "libgncmod-engine",
+        "libgncmod-generic-import",
+        "libgncmod-gnome-search",
+        "libgncmod-gnome-utils",
+        "libgncmod-html",
+        "libgncmod-ledger-core",
+        "libgncmod-locale-reports-us",
+        "libgncmod-log-replay",
+        "libgncmod-qif-import",
+        "libgncmod-register-core",
+        "libgncmod-register-gnome",
+        "libgncmod-report-gnome",
+        "libgncmod-report-system",
+        "libgncmod-stylesheets",
+        "libgncmod-tax-us"
+    };
+    static const unsigned len = G_N_ELEMENTS (excluded_modules);
+    unsigned namelen = strchr(module, '.') ?
+        strchr(module, '.') - module : strlen (module);
+    for (unsigned i = 0; i < len; ++i)
+        if (strncmp(excluded_modules[i], module, MIN(namelen, strlen(excluded_modules[i]))) == 0)
+            return TRUE;
+    return FALSE;
+}
 
 /*************************************************************
  * gnc_module_system_refresh
@@ -198,8 +236,9 @@ gnc_module_system_refresh(void)
              * other platforms.
              */
             if ((g_str_has_suffix(dent, "." G_MODULE_SUFFIX)
-                    || g_str_has_suffix(dent, ".dylib"))
-                    && g_str_has_prefix(dent, GNC_MODULE_PREFIX))
+                 || g_str_has_suffix(dent, ".dylib"))
+                && g_str_has_prefix(dent, GNC_MODULE_PREFIX)
+                && !exclude_module(dent))
             {
                 /* get the full path name, then dlopen the library and see
                  * if it has the appropriate symbols to be a gnc_module */



Summary of changes:
 libgnucash/gnc-module/gnc-module.c | 45 +++++++++++++++++++++++++++++++++++---
 1 file changed, 42 insertions(+), 3 deletions(-)



More information about the gnucash-changes mailing list