GnuCash
Contact   Instructions
Bug 797900 - Crash caused by Quitting while Check and Repair All is running
Summary: Crash caused by Quitting while Check and Repair All is running
Status: RESOLVED FIXED
Alias: None
Product: GnuCash
Classification: Unclassified
Component: User Interface General (show other bugs)
Version: 4.1
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: ui
QA Contact: ui
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-07 17:00 EDT by Michael Hendry
Modified: 2020-09-05 18:57 EDT (History)
6 users (show)

See Also:


Attachments
Crash log caused by quitting while Check & Repair was running (89.81 KB, text/plain)
2020-08-10 14:01 EDT, Michael Hendry
no flags Details

Description Michael Hendry 2020-08-07 17:00:25 EDT
There is no activity indicator after Check and Repair All is chosen. I found it was possible to click on the menu headings, but the options were greyed out, but I was able to use File>Quit to shut Gnucash down. Shortly afterwards I got a crash report (Segmentation Fault).

I was running this operation on a series of files after they had first been opened with 4.1 and then closed, and was probably moving faster than I normally would so as to get on with the next file.

To reproduce the crash, open a file, run Check and Repair All, and within a few seconds use File>Quit.

To work around the problem, leave Check and Repair to run to completion before quitting (if in doubt, use Activity Monitor to follow GnuCash's CPU usage - in my case when it dropped from 90% to 2% it was safe to quit.
Comment 1 Michael Hendry 2020-08-10 02:30:50 EDT
Link to thread on Gnucash Users mailing list:

https://lists.gnucash.org/pipermail/gnucash-user/2020-August/092459.html
Comment 2 Jean Laroche 2020-08-10 12:27:20 EDT
I can pick up this bug if nobody's working on it.
Jean
Comment 3 John Ralls 2020-08-10 13:56:20 EDT
Jean, sure, go ahead.
Michael, please attach the crash report.
Comment 4 Michael Hendry 2020-08-10 14:01:56 EDT
Created attachment 373820 [details]
Crash log caused by quitting while Check & Repair was running
Comment 5 Jean Laroche 2020-08-20 12:55:44 EDT
I'm able to easily reproduce the issue. Note to devs:
There's already a mechanism in GC to query each page before it's destroyed. 
The finish_pending() function returns a boolean to indicate whether the page is ready to quit. This is called via gnc_main_window_all_finish_pending() before exiting.

It's easy to add a call to gnc_gui_refresh_suspended() to determine if an action is going on, and return FALSE if something's happening. Indeed this solves the issue.

But I wonder why the default behavior is not to disallow quitting if gnc_gui_refresh_suspended() returns true as this indicates something's currently going on.

In other words, why is it that
gnc_quartz_should_quit() which calls gnc_main_window_all_finish_pending() does not also call gnc_gui_refresh_suspended() to determine whether an action is currently pending.

Any idea what that's not the case?
Comment 6 Jean Laroche 2020-08-20 13:09:14 EDT
Also, the repair mechanism does not seem to have a "cancel" or "abort" option. On a very large database, the repair takes forever, and the user has no way to interrupt it.
Would it be worth adding that? Perhaps as part of the protection against quitting?

For example:

When the user attempts to quit, and the repair is ongoing, an alert window pops up "A repair action is in progress, do you want to abort it?". Abort and quit or cancel the quitting based on the user's response...

Jean
Comment 7 Geert Janssens 2020-08-21 04:33:53 EDT
Cancel or Abort are good if you are able to implement it safely.

Visual feedback on the progress of the check & repair run would at least be as helpful.
Comment 8 John Ralls 2020-08-21 11:15:26 EDT
I think it will take some SQL backend work to cancel safely: You'd need to checkpoint the DB and roll back to the checkpoint on cancel.

For XML GnuCash should do a save at the beginning of the C&R and reload if the user cancels.
Comment 9 Jean Laroche 2020-08-21 12:42:37 EDT
1) there's already visual feedback of the progress. It does not seem to work very well in debug mode, but it's there.
2) By canceling, I really meant aborting, but not reverting back to the original state: not an "undo". The repair works split by split, so it's very easy to put a flag and stop the process in between two splits. At least that way you don't get a crash (possibly leaving the database in an unreadable state) and the database would be left in a good state (not fully repaired but not damaged).
Comment 10 Michael Hendry 2020-08-21 16:23:21 EDT
Possibly connected with this bug is a crash which happened yesterday, but which I haven't as yet been able to repeat.

I started GnuCash which opened the most recently used file. Having checked that the "Save" option was greyed out, I used File->Open and selected the file I wanted to access.

My suspicion is that although there were no Scheduled transactions set up in the first file, that GnuCash was busy with this file, but still allowed me to attempt the opening of a second file.
Comment 11 John Ralls 2020-08-21 17:00:38 EDT
Michael, Since you're on a mac please always attach a the Console.app crash report when you report a crash. It makes it much easier to diagnose and to correlate with other bugs. Thanks.
Comment 12 Michael Hendry 2020-08-22 02:17:13 EDT
Apologies. Have reproduced the crash this morning and will attach the crash log to a new bug report (as this wasn't triggered in the same way).
Comment 13 John Ralls 2020-09-05 18:57:07 EDT
Jean Laroche's PR for the original bug is merged and will be in GnuCash 4.2.

For the curious, Michael's new bug is bug 797918.

Note You need to log in before you can comment on or make changes to this bug.