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 674283 - (mysql_del_acc_crash) With mysql crash after deleting accounts included into a budget
(mysql_del_acc_crash)
With mysql crash after deleting accounts included into a budget
Status: RESOLVED FIXED
Product: GnuCash
Classification: Other
Component: Backend - SQL
2.4.x
Other Linux
: Normal major
: ---
Assigned To: Phil Longstaff
Geert Janssens
: 643363 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-04-17 19:52 UTC by Gabriele Vivinetto
Modified: 2018-06-29 23:08 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Gabriele Vivinetto 2012-04-17 19:52:59 UTC
Create a bidget that includes all accounts
Delete two accounts that are empty
Close gnucash
Open gnucash
It says:
 GnuCash could not obtain the lock for mysql://gnucash:xxxxx@localhost/gnucash.  That database may be in use by another user, in which case you should not open the database. What would you like to do?

Try to select
 Open Anyway
You get a 
 Segmentation fault

The tracefile says:
 WARN <gnc.backend.sql> [load_account_guid()] Account ref  d9dfe368df7d7346aac10bf09023972f' not found

The backtrace with debugging symbols is at http://pastebin.com/u17DeWym

Comparing the mysqldump before and after the crash, I recovered my data adding back the two deleted accounts
 INSERT INTO `accounts` VALUES ('9c3390b42097dedb2331acbb304ce23e','Orfano-EUR','BANK','0b5cfa6f4257a5587f779ed74429427a',100,0,'0d3d4d3637a21abc16e19624ed3c9b0a','','',0,0);
 INSERT INTO `accounts` VALUES ('d9dfe368df7d7346aac10bf09023972f','Sbilancio-EUR','BANK','0b5cfa6f4257a5587f779ed74429427a',100,0,'0d3d4d3637a21abc16e19624ed3c9b0a','','',0,0);
Comment 1 John Ralls 2012-04-17 20:43:30 UTC
For convenience and long-term record, here's the stack trace:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff309a540 in g_type_check_instance_cast ()
   from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
(gdb) bt
  • #0 g_type_check_instance_cast
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #1 gnc_budget_set_account_period_value
    at gnc-budget.c line 512
  • #2 set_amount
    at gnc-budget-sql.c line 185
  • #3 load_numeric
    at gnc-backend-sql.c line 2240
  • #4 gnc_sql_load_object
    at gnc-backend-sql.c line 2475
  • #5 load_budget_amounts
    at gnc-budget-sql.c line 223
  • #6 load_single_budget
    at gnc-budget-sql.c line 321
  • #7 load_all_budgets
    at gnc-budget-sql.c line 354
  • #8 initial_load_cb
    at gnc-backend-sql.c line 212
  • #9 foreach_backend
    at qofobject.c line 378
  • #10 g_hash_table_foreach_sorted
    at qofutil.c line 47
  • #11 qof_object_foreach_backend
    at qofobject.c line 398
  • #12 gnc_sql_load
    at gnc-backend-sql.c line 261
  • #13 gnc_dbi_load
    at gnc-backend-dbi.c line 1270
  • #14 qof_session_load
    at qofsession.c line 1244
  • #15 gnc_post_file_open
    at gnc-file.c line 793
  • #16 gnc_file_open_file
    at gnc-file.c line 955
  • #17 inner_main
    at gnucash-bin.c line 721
  • #18 ??
    from /usr/lib/libguile.so.17
  • #19 ??
    from /usr/lib/libguile.so.17
  • #20 scm_c_catch
    from /usr/lib/libguile.so.17
  • #21 scm_i_with_continuation_barrier
    from /usr/lib/libguile.so.17
  • #22 scm_c_with_continuation_barrier
    from /usr/lib/libguile.so.17
  • #23 scm_i_with_guile_and_parent
    from /usr/lib/libguile.so.17
  • #24 scm_boot_guile
    from /usr/lib/libguile.so.17
  • #25 main
    at gnucash-bin.c line 879

Comment 2 John Ralls 2012-04-17 20:53:59 UTC
That's a rather insidious crash. It appears that the account object being passed contains pointers either to freed memory or to memory outside of the process address space. That might be a result of the screwed up memory management in the engine, which will get fixed in due course (but not in 2.4.x).

Can you crash it again in the debugger, switch to frame 1, p *account, and post the results?

Did you delete the accounts using MySql or from inside Gnucash? Do I understand correctly that using MySql to reinsert the account records made the database loadable once more?
Comment 3 Gabriele Vivinetto 2012-04-18 09:11:08 UTC
I'm not used to gdb, so If you can help me a little bit more, I'll try to get the backtrace the way you need. If you can, you can join me on #gnucash on IRC.

Before the problem, I deleted the accounts from inside gnucash. Never acted directly on the database manually.

After deleting these accounts, I normally closed gnucash, without errors.
When I reopened it, I received the error.

To fix things, i had to manually execute the two INSERT sql queries to readd the accounts.
After this, gnucash was able to reopen the database without any clue.

I have the pre and post crash mysqldumps of the databases If you need them.
Comment 4 Gabriele Vivinetto 2012-04-18 09:12:55 UTC
Another note: I can reproduce the crash with the database dumps.
I tried to export my data to xml, and made the same operations that lead me to the crash, but the crash didn't occur. So I think it's a problem totally related to sql stuffs ...
Comment 5 John Ralls 2012-04-18 14:24:20 UTC
I can't IRC with you today, maybe tomorrow.

The gdb commands are:
f 1                  to switch to frame 1 of the backtrace
p *account           to print the account structure
 

However, I suspect that the problem is that deleting the account isn't marking the budget "dirty", so it isn't getting written out to the DB. I'll have a look at that on Thursday.
Comment 6 John Ralls 2012-04-19 17:33:31 UTC
*** Bug 643363 has been marked as a duplicate of this bug. ***
Comment 7 John Ralls 2012-04-19 17:40:08 UTC
Can you look in the after-deleting-the-account XML file (it might be gzipped unless you've told it not to in preferences) and paste the budget element here?
Comment 8 John Ralls 2012-04-20 19:34:45 UTC
Never mind, I can replicate the crash now.

As a work around, you can do a "file save all" to your database after deleting an account, which will save the budget in the correct state.
Comment 9 John Ralls 2012-04-21 17:56:58 UTC
Fixed with r22154/22155.
Comment 10 John Ralls 2017-09-24 22:46:18 UTC
Reassign version to 2.4.x so that individual 2.4 versions can be retired.
Comment 11 John Ralls 2018-06-29 23:08:20 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=674283. Please update any external references or bookmarks.