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 502646 - Win32: Crash entering dates before 1/1/1970 in dialogs
Win32: Crash entering dates before 1/1/1970 in dialogs
Status: VERIFIED FIXED
Product: GnuCash
Classification: Other
Component: User Interface General
2.2.x
Other All
: Normal critical
: ---
Assigned To: Charles Day
Chris Shoemaker
Depends on:
Blocks: backport
 
 
Reported: 2007-12-09 11:54 UTC by Charles Day
Modified: 2018-06-29 21:56 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Charles Day 2007-12-09 11:54:45 UTC
Steps to reproduce:
1. Run a transaction report.
2. Click Options
3. Enter 12/31/1969 for the start date.

This bug is not specific to reporting. For example, you can also enter 12/31/1969 in the dialog box that pops up when you go into an account register and pick Action->Schedule from the menu.

Stack trace:
gdb: kernel event for pid=2844 tid=5360 code=EXCEPTION_DEBUG_EVENT)
gdb: Target exception EXCEPTION_ACCESS_VIOLATION at 0x63c29b5c

Program received signal SIGSEGV, Segmentation fault.
0x63c29b5c in gnc_date_edit_set_time_tm (gde=0x3c51958, mytm=0x0)
    at ../../../src/gnome-utils/gnc-date-edit.c:500
500     ../../../src/gnome-utils/gnc-date-edit.c: No such file or directory.
        in ../../../src/gnome-utils/gnc-date-edit.c
(gdb) bt
  • #0 gnc_date_edit_set_time_tm
    at ../../../src/gnome-utils/gnc-date-edit.c line 500
  • #1 gnc_date_edit_set_time
    at ../../../src/gnome-utils/gnc-date-edit.c line 535
  • #2 date_focus_out_event
    at ../../../src/gnome-utils/gnc-date-edit.c line 624
  • #3 _libmsvcrt_a_iname
    from C:\Program

Other information:
It looks like the date entered by the user is not check properly to make sure that it is 1970 or later. If a date before 1/1/1970 is entered, a warning should pop up and the date should return to its prior value.

Also, function gnc_date_edit_set_time_tm in gnome-utils/gnc-date-edit.c does not check whether parameter mytm is non-null before using it. This is what causes the segmentation fault.
Comment 1 Will Luo 2008-04-24 15:56:58 UTC
just wanted to report another use case where this bug could be triggered. this is the gnucash 2.2.4 windows build i downloaded from gnucash.org. my gnucash crashed when i tried to reconcile an account that doesn't have a "gnc_reconcile_last_statement_date" somehow (see gnucash/repos/src/gnome/window-reconcile.c recnWindow()). this is the stacktrace i got:

  • #0 gnc_date_edit_set_time_tm
    at ../../../repos/src/gnome-utils/gnc-date-edit.c line 500
  • #1 gnc_date_edit_set_time
    at ../../../repos/src/gnome-utils/gnc-date-edit.c line 535
  • #2 gnc_date_edit_new_flags
    at ../../../repos/src/gnome-utils/gnc-date-edit.c line 796
  • #3 gnc_date_edit_new
    at ../../../repos/src/gnome-utils/gnc-date-edit.c line 745
  • #4 startRecnWindow
    at ../../../repos/src/gnome/window-reconcile.c line 688
  • #5 recnWindow
    at ../../../repos/src/gnome/window-reconcile.c line 1489
  • #6 gnc_plugin_page_account_tree_cmd_reconcile
    at ../../../repos/src/gnome/gnc-plugin-page-account-tree.c line 1157
  • #7 g_closure_invoke
    from c:\soft\gnome\bin\libgobject-2.0-0.dll
  • #8 signal_emit_unlocked_R
    from c:\soft\gnome\bin\libgobject-2.0-0.dll

and the cause seems to be the same as what Charles Day reported, that gnc_date_edit_set_time_tm() does not check if mytm is NULL before dereferencing it. this patch seems to fix the reconcile crash for me, but it doesn't fix the bug that you're not able to specify a time range starting before 1/1/1970.

Index: gnc-date-edit.c
===================================================================
--- gnc-date-edit.c	(revision 17123)
+++ gnc-date-edit.c	(working copy)
@@ -497,6 +497,13 @@
 	char buffer [40];
 
 	/* Set the date */
+	if (!mytm)
+	{
+		gtk_entry_set_text (GTK_ENTRY (gde->date_entry), "");
+		gtk_entry_set_text (GTK_ENTRY (gde->time_entry), "");
+		return;
+	}
+
 	qof_print_date_dmy_buff (buffer, 40,
                    mytm->tm_mday,
                    mytm->tm_mon + 1,

(also a better fix would be to populate gde->date_entry with the current date...)
Comment 2 Charles Day 2008-07-14 16:18:19 UTC
Fix committed as r17327. Requesting backport for 2.2.

If an invalid date is entered (i.e. a date not supported by time_t) the date now reverts to the last valid date entered or, as a last resort, the beginning of the current day.
Comment 3 Andreas Köhler 2008-07-22 23:02:49 UTC
Applied to branches/2.2 as r17386 for inclusion in GnuCash 2.2.6.
Thanks!
Comment 4 John Ralls 2018-06-29 21:56:01 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=502646. Please update any external references or bookmarks.