After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 674862 - Gnucash crashes after creating a new SX using the Mortgage Wizard and SQL Backend
Gnucash crashes after creating a new SX using the Mortgage Wizard and SQL Bac...
Status: RESOLVED FIXED
Product: GnuCash
Classification: Other
Component: Backend - SQL
2.4.x
Other Windows
: Normal major
: future
Assigned To: John Ralls
Depends on:
Blocks:
 
 
Reported: 2012-04-26 11:20 UTC by Sergi
Modified: 2018-06-29 23:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Tracefile and MySQL DB dump (12.67 KB, application/zip)
2012-04-26 11:20 UTC, Sergi
Details

Description Sergi 2012-04-26 11:20:37 UTC
Created attachment 212867 [details]
Tracefile and MySQL DB dump

Describe the problem:
After creating a new SX using the Mortgage Wizard, if you are using the MySQL Backend, Gnucash is not able to run again. When you create the SX you can still work with Gnucash, but after closing it, when you try to open it again it crashes always. The message from Windows is just that gnucash has crashed and will be terminated. The error in the Trace log file:
* 12:25:56  INFO <gnc.account> [xaccAccountRecomputeBalance] acct=abf51b2b12142ec572094df4918c2429 starting baln=0/1
* 12:25:56  CRIT <GLib> g_date_new_dmy: assertion `g_date_valid_dmy (day, m, y)' failed
* 12:25:56  CRIT <GLib> g_date_valid: assertion `d != NULL' failed

Steps to reproduce:
- Create a new book: During the Wizard select common, fixed assets and mortgage accounts. Also put 200.000,00€ in the liabilities:mortgage against the assets:fixed:home as the opening balance.
- Store the new created book with the MySQL backend.
- Run the Mortgage Wizard (leave default values if not indicated a specific value):
  - First screen:
     - Loan Account: liabilities:mortgage (where you have put the 200.000,00€)
     - Amount: 200000,00
     - Interest: 2,487%
     - Start date: 2012-05-01
     - Length: 480 months
  - Second screen: Nothing to select here, leave defaults (everything unchecked)
  - Third screen:
     - Pay from: select a paycheck account from assets.
     - Interest to: select the expenses:mortgage interest account.
     - Frequency: Monthly
     - Start: 2012-05-01
     - Every month, First day of month, without changes in weekends.
- Finish the wizard, save your book and close gnucash.
- Open gnucash
- Insert password of the MySQL database
- Crashes when loading user data

- Does this happen every time?
Yes

Environment:
- Windows 7
- MySQL Server 5.5.17
- Gnucash 2.4.10

Attachments (in a zip file):
- Gnucash Tracefile running with '--debug'
- MySQL dump of the crashing Database: this database just contains the openning entry and the crashing SX.

Additional Information:
If you use the XML data store this error is not happening there. If you create the SX using the XML data store gnucash will not crash.
But if you create the SX using the XML data store, and after that you "Save As" the book and save it as MySQL, then when you try to open the MySQL book it will crash, however the XML one will open correctly.
Comment 1 Sergi 2012-04-26 13:02:13 UTC
Moved to SQL Backend component, since I think it is more accurate for this issue.
Comment 2 John Ralls 2012-04-26 22:37:48 UTC
Well, I finally replicated it, but it only happens on Windows and not only does it not crash with the XML backend, it also works fine with SQLite3. I'll check with Postgresql too just to be sure, but it's starting to smell like a MySQL-on-Windows issue.
Comment 3 John Ralls 2012-04-27 22:53:31 UTC
Same problems with Postgres, again only on Windows.
Comment 4 H. 2012-05-05 14:50:47 UTC
It seems that I have very similar problem with Gnucash 2.4.10 on Linux (Kubuntu 12.04) with Postgresql.
John Ralls asked me in this mail list: http://lists.gnucash.org/pipermail/gnucash-user/2012-May/044670.html to describe my problem here.

I may have Mortgage Wizard created transactions, because I play a little with this option, although I am not 100% sure, because this was quite a long ago.

Below I have posted gdb stacktrace from my case (Gnucash 2.4.10 installed from source), as John suggested. 


#########stacktrace###########################

(gdb) continue
Continuing.
[New Thread 0x7fae768eb700 (LWP 31811)]

Program received signal SIGSEGV, Segmentation fault.
xaccSchedXactionSetStartDate (sx=0x151eaa0, newStart=0x0) at SchedXaction.c:591
591         sx->start_date = *newStart;
(gdb) bt
  • #0 xaccSchedXactionSetStartDate
    at SchedXaction.c line 591
  • #1 g_object_set_valist
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #2 g_object_set
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #3 load_date
    at gnc-backend-sql.c line 2100
  • #4 gnc_sql_load_object
    at gnc-backend-sql.c line 2479
  • #5 load_single_sx
    at gnc-schedxaction-sql.c line 96
  • #6 load_all_sxes
    at gnc-schedxaction-sql.c line 131
  • #7 g_hash_table_foreach_sorted
    at qofutil.c line 47
  • #8 qof_object_foreach_backend
    at qofobject.c line 398
  • #9 gnc_sql_load
    at gnc-backend-sql.c line 261
  • #10 gnc_dbi_load
    at gnc-backend-dbi.c line 1349
  • #11 qof_session_load
    at qofsession.c line 1256
  • #12 gnc_post_file_open
    at gnc-file.c line 912
  • #13 gnc_plugin_file_history_cmd_open_file
    at gnc-plugin-file-history.c line 728
  • #14 g_closure_invoke
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #15 ??
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #16 g_signal_emit_valist
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #17 g_signal_emit
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #18 ??
    from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
  • #19 g_closure_invoke
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #20 ??
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #21 g_signal_emit_valist
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #22 g_signal_emit
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #23 gtk_widget_activate
    from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
  • #24 gtk_menu_shell_activate_item
    from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
  • #25 ??
    from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
  • #26 ??
    from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
  • #27 g_closure_invoke
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #28 ??
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #29 g_signal_emit_valist
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #30 g_signal_emit
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #31 ??
    from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
  • #32 gtk_propagate_event
    from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
  • #33 gtk_main_do_event
    from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
  • #34 ??
    from /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0
  • #35 g_main_context_dispatch
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #36 ??
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #37 g_main_loop_run
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #38 gtk_main
    from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
  • #39 gnc_ui_start_event_loop
    at gnc-gnome-utils.c line 668
  • #40 inner_main
    at gnucash-bin.c line 735
  • #41 ??
    from /usr/lib/libguile.so.17
  • #42 ??
    from /usr/lib/libguile.so.17
  • #43 scm_c_catch
    from /usr/lib/libguile.so.17
  • #44 scm_i_with_continuation_barrier
    from /usr/lib/libguile.so.17
  • #45 scm_c_with_continuation_barrier
    from /usr/lib/libguile.so.17
  • #46 scm_i_with_guile_and_parent
    from /usr/lib/libguile.so.17
  • #47 scm_boot_guile
    from /usr/lib/libguile.so.17
  • #48 main
    at gnucash-bin.c line 879

#####################################

Actually, in my case, I could try to remove mortgage wizard transactions from psql, if you could direct me where to search for such transactions? 
Gnucash schema tables looks very complicated for me, and I couldn't find clear description of how this tables are organized in Postgresql.

Thank you for help!
Krzysiek
Comment 5 John Ralls 2012-05-07 23:11:43 UTC
I've committed to trunk (not yet backported) some sanity checks in the SX date functions to prevent crashes. Not really a complete answer, because the backend is still storing bogus date strings somehow.
Comment 6 H. 2012-05-10 09:40:47 UTC
My problems was caused by improper datestyle in Postgresql database, and was not related to Mortgage Wizzard. The full description could be found at: http://lists.gnucash.org/pipermail/gnucash-user/2012-May/044723.html

You could remove my comments, as they are not relevant to this thread.

Best Regards,
H.
Comment 7 John Ralls 2012-05-21 23:40:27 UTC
Well, I can't remove your comments anyway, but it turns out that your problem is indeed relevant.

The sanity checks do prevent the crash in both cases, but don't really fix the root cause of the problem. In the case of the mortgage wizard, the problem is that libdbi returns a time_t, which is subject to the 2038 bug. The 40-year mortgage writes an end-date past 2038, and the returned time_t is -1.

The reason it crashes only in Windows is that on Linux and MacOSX, gmtime(-1) returns {tm_sec = 59, tm_min = 59, tm_hour = 23, tm_mday = 31, tm_mon = 11, 
  tm_year = 69, tm_wday = 3, tm_yday = 364, tm_isdst = 0, tm_gmtoff = 0, 
  tm_zone = 0xb6d1525c "GMT"}, the mingw implementation returns garbage:
{tm_sec = 122599504, tm_min = 1751162088, tm_hour = 89774067, 
  tm_mday = 89788426, tm_mon = 0, tm_year = 1973917914, tm_wday = 1571828185, 
  tm_yday = 55110248, tm_isdst = 2685208}. GDate can digest the former but returns a NULL for the latter -- which is what precipitates the crash.

So I've committed and backported a fix that works around the MinGW bug and backported the earlier change which further guards against NULL GDates.
That correct the immediate problem of this bug, but to fix the underlying problem the date extraction will have to be rewritten to use dbi_result_get_string() and parse the result.
Comment 8 John Ralls 2013-09-19 16:33:57 UTC
This problem has been fixed in our software repository. The fix will go into the next software release. Thank you for your bug report.
r23174 trunk, backported to 2.4 in 23177.
Note that 2.4 doesn't have the rewrite of gnc-date to make it 2038 safe. That will be released in Gnucash 2.6.

I also filed a bug upstream with libdbi: https://sourceforge.net/p/libdbi/bugs/15/
Comment 9 John Ralls 2017-09-24 22:46:15 UTC
Reassign version to 2.4.x so that individual 2.4 versions can be retired.
Comment 10 John Ralls 2018-06-29 23:08:28 UTC
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=674862. Please update any external references or bookmarks.