GNOME Bugzilla – Bug 366468
Crash when creating a new stock account
Last modified: 2018-06-29 21:14:28 UTC
In the Create New Account Dialog, I had selected 'Stock' type and created a new commodity for the commodity field. Then, I clicked 'ok', and got the following. This is r14992 on trunk. I had just clicked 'ok' in the Create New Account dialog.
+ Trace 79426
Notes: This was in the log: Error: xaccAccountTypesCompatibleWith(): bad account type: -1 I think that means that gnc_account_parent_changed_cb() must have set the aw->type to ACCT_TYPE_INVALID at some time, but aw->type seems to correctly be ACCT_TYPE_STOCK at the point of the crash. And this was in the console: (gnucash:13831): GLib-GObject-WARNING **: invalid cast from `GncEmbeddedWindow' to `GncMainWindow' (gnucash:13831): GLib-GObject-WARNING **: attempt to retrieve private data for invalid type 'GncMainWindow' I had the Checking Account open in a register, and I had two instances of GnuCash running at the time. I couldn't reproduce this when I tried again. I attached gdb to this instance and noticed something strange. In the gppr_account_destroy_cb() frame citem = gnc_gobject_tracking_get_list(GNC_PLUGIN_PAGE_REGISTER_NAME); had returned a list of 4 pages, even though I had only one register open. 3 of them were added to the kill list, and the first item was the one that was crashing upon _close_page(). 'account' is an empty, bare, account. It has a valid QofType of "Account" but it has no children or parent Groups, and its type is ACCT_TYPE_INVALID. This account's guid _does_ match the AccountWindow.account guid. Ok, I think I understand now. New comment...
Here's what's happening. Key info: I had the SLR dialog still open from it opening automatically at startup. When creating a new account, gppr_account_destroy_cb() gets called. Its function is to close all registers that are either for the given account and General Ledgers. This search finds the register(s?) in the GncEmbeddedWindow belonging to the SLR dialog. But, it assumes that the pages belong to the GncMainWindow so it calls gnc_main_window_close_page(). This is wrong, and it's not handled gracefully, so it crashes. I think there are two ways to fix it. Quick way) Teach gnc_main_window_close_page() or gppr_account_destroy_cb() to be more restrictive. Right way) IMO, the gppr_account_destroy_cb() isn't the right mechanism for closing registers whose account type has changed. Instead, the component manager offers this functionality, and it should be used. That way, the logic for when to delete the object resides in the component that would be closed. That would prevent problems like this - making incorrect assumptions about what types of objects exist.
*** Bug 400459 has been marked as a duplicate of this bug. ***
*** Bug 406870 has been marked as a duplicate of this bug. ***
*** Bug 411203 has been marked as a duplicate of this bug. ***
*** Bug 426414 has been marked as a duplicate of this bug. ***
*** Bug 431204 has been marked as a duplicate of this bug. ***
*** Bug 431453 has been marked as a duplicate of this bug. ***
*** Bug 435477 has been marked as a duplicate of this bug. ***
*** Bug 442903 has been marked as a duplicate of this bug. ***
*** Bug 436916 has been marked as a duplicate of this bug. ***
*** Bug 441411 has been marked as a duplicate of this bug. ***
*** Bug 441515 has been marked as a duplicate of this bug. ***
*** Bug 441709 has been marked as a duplicate of this bug. ***
*** Bug 442385 has been marked as a duplicate of this bug. ***
*** Bug 442008 has been marked as a duplicate of this bug. ***
*** Bug 446376 has been marked as a duplicate of this bug. ***
Workaround. Based on the comments about closing accounts etc. I found that if the only gnucash window open is the main window listing accounts, there's no crash in adding a new account. When another window was open e.g. confirmation of scheduled transactions, adding another account crashed gnucash. At least I can now continue using this package.
*** Bug 449593 has been marked as a duplicate of this bug. ***
Could we just fix this "the quick way" by adding in gnc_main_window_close_page an additional check if (!GNC_IS_MAIN_WINDOW(page->window)) return; right before the GNC_MAIN_WINDOW(...) case? Sounds to me this should at least fix the crashes.
*** Bug 449889 has been marked as a duplicate of this bug. ***
The crash can be reproduced with SVN-trunk as of today if the Scheduled Transaction Editor is open, and a new account is being created. Crash on Ok. Once I add the lines from comment#20, it does no longer crash. I now get this warning: * 22:33:18 CRIT <Gtk> gtk_widget_event: assertion `WIDGET_REALIZED_FOR_EVENT (widget, event)' failed but apart from that at least we don't have a crash. I committed this workaround as r16207 which will be in 2.1.5 or 2.2.0 any later version.
*** Bug 450640 has been marked as a duplicate of this bug. ***
*** Bug 451115 has been marked as a duplicate of this bug. ***
*** Bug 451343 has been marked as a duplicate of this bug. ***
*** Bug 448024 has been marked as a duplicate of this bug. ***
*** Bug 452563 has been marked as a duplicate of this bug. ***
*** Bug 453262 has been marked as a duplicate of this bug. ***
*** Bug 465312 has been marked as a duplicate of this bug. ***
*** Bug 470257 has been marked as a duplicate of this bug. ***
*** Bug 470568 has been marked as a duplicate of this bug. ***
*** Bug 472598 has been marked as a duplicate of this bug. ***
*** Bug 480709 has been marked as a duplicate of this bug. ***
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=366468. Please update any external references or bookmarks.