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 514492 - Win32: Crash when loading data file with invalid txn dates
Win32: Crash when loading data file with invalid txn dates
Status: VERIFIED FIXED
Product: GnuCash
Classification: Other
Component: Windows
2.2.x
Other Windows
: Normal critical
: ---
Assigned To: Andreas Köhler
Christian Stimming
Depends on:
Blocks:
 
 
Reported: 2008-02-05 10:10 UTC by W S Burdick
Modified: 2018-06-29 22:00 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description W S Burdick 2008-02-05 10:10:58 UTC
I have a problem opening an xac file I use in Linux Gnucash 2.2.3 when I try to open it in Windows (both XP and Vista). I get an error message: "gnucash-bin.exe has encountered a problem and needs to close.  We are sorry for the inconvenience."

The thermometer at the lower right moves nicely to the right until it gets about 3/4 of the way. Then it stops and the message pops up. This happens on my Acer Aspire 9300 (XP), Acer 4620Z (Vista) and my daughter's Acer (?) (XP). 

The same file opens just fine on the SuSE 10.3 Gnucash on my Apire 9300. 

The file is large: 1009KB. A smaller file (743KB) (also a xac) will open on my XP Aspire just fine. Everything seems normal. 

I don't know if it is a file size issue or not.
Comment 1 Andreas Köhler 2008-02-05 21:14:03 UTC
Thanks for the report.  As you may have expected we need more information to help you :-)

What about error messages?  http://wiki.gnucash.org/wiki/Windows#Error_messages . 

Is your file compressed?  If you open it in an editor you can either read the xml or see binary data.  In the latter case please uncompress it using 7-zip and see whether that changes anything.

Once your file is uncompressed and you made a backup of the original, you can start modifying it with an editor, removing complete global xml elements until gnucash loads it again.  If you can track it down to some small portion, please attach that here.  Maybe you also find a way to reproduce the crash with an empty or small test file.

Last but not least you can also send me your file privately so I do that work for you :-)
Comment 2 W S Burdick 2008-02-06 10:51:03 UTC
There are no Gnucash error messages. 

It turns out the file is compressed, but I also tried an earlier saved version which was not compressed (9.34MB) I got the same failure. I unzipped my current file. It is now 10.069MB. Gnucash fails the same way. 

I have been chopping off transactions starting at the end of the file. It appears to be this transaction that makes it fail.

<gnc:transaction version="2.0.0">
  <trn:id type="guid">fa444113c4a2f3fde67ff8603cda7ac5</trn:id>
  <trn:currency>
    <cmdty:space>ISO4217</cmdty:space>
    <cmdty:id>USD</cmdty:id>
  </trn:currency>
  <trn:date-posted>
    <ts:date>1969-12-31 00:00:00 -0500</ts:date>
  </trn:date-posted>
  <trn:date-entered>
    <ts:date>2007-03-27 19:09:03 -0400</ts:date>
    <ts:ns>344892000</ts:ns>
  </trn:date-entered>
  <trn:description>Interest</trn:description>
  <trn:splits>
    <trn:split>
      <split:id type="guid">dcf18bf70569e6dad0a17cb530cbc3ee</split:id>
      <split:reconciled-state>n</split:reconciled-state>
      <split:value>9463/100</split:value>
      <split:quantity>9463/100</split:quantity>
      <split:account type="guid">580540231dc0de38087762a6def5350f</split:account>
    </trn:split>
    <trn:split>
      <split:id type="guid">d9d109d1426d00ccaef1742988ad8dfc</split:id>
      <split:reconciled-state>y</split:reconciled-state>
      <split:reconcile-date>
        <ts:date>2011-01-11 00:00:00 -0500</ts:date>
      </split:reconcile-date>
      <split:value>-9463/100</split:value>
      <split:quantity>-9463/100</split:quantity>
      <split:account type="guid">248c107c11928aba1ec9c2129ed267f2</split:account>
    </trn:split>
  </trn:splits>
</gnc:transaction>

Just in case it was the length of the file or what ever, I also left this transaction and removed earlier ones. If this one is in the file, it won't open (the few times I have tried). 

Does this help? 
Comment 3 Andreas Köhler 2008-02-07 00:10:04 UTC
Yep.  Thanks a lot!
Comment 4 W S Burdick 2008-02-07 09:26:34 UTC
Here is a bit more to the puzzle.

I tried to leave the questionable transaction in and remove a lot more (about 200K of file size) out. The file loaded.

On the other hand if I go back to the original 10,069KB uncompressed file and remove that one transaction (fa444113c4a2f3fde67ff8603cda7ac5), the file also loads. 

Do you have any suggestions about other things I can try? Do you want to see the file? 

Thanks for your help. 
Comment 5 W S Burdick 2008-02-07 10:23:51 UTC
One new thing I noticed which may be significant. 

If I change this line (the 8th line in the above transaction)
<ts:date>1969-12-31 00:00:00 -0500</ts:date>

to 
<ts:date>2007-02-31 00:00:00 -0500</ts:date>

The file opens. This is the only line with the (obviously incorrect) 1969 date. 

Maybe MS has a problem with the date....

Thanks again. 
Comment 6 Andreas Köhler 2008-02-07 11:53:26 UTC
Oh, I forgot to tell you about that work-around.  I am sorry for that.
Actually, the information you provided is enough to reproduce the bug and I will try to work on it.
Comment 7 Geert Janssens 2011-10-07 16:08:53 UTC
I tried to reproduce this on a recent development build (r21371) and the crash no longer happens.

Things are not ok yet though. The 1969-12-31 00:00:00 -0500 date is still causing trouble.

Instead of crashing, it will now be replaced with a random date in the future.

So the core issue remains: how to deal with invalid dates properly ?

My guess would be to inform the user, but continue to work with a default date instead. The first allowed date would be my suggestion.
Comment 8 Geert Janssens 2011-10-07 16:15:52 UTC
Oh, and if other devs want to look into this as well, I think the issue starts in function set_tran_date in src/backend/xml/gnc-transaction-vc.c:433

This function first tries to generate a time_t from the string found in the xml file. It calls the function dom_tree_to_timespec for that. That function has a sanity check to verify if the calculated time_t is not -1 (invalid time_t), but at present the calculated time in seconds is never -1, not even on the 1969-12-31 date. So the sanity check fails.

Result: a negative time in seconds is stored in the loaded transaction.

Should the sanity check have worked, then no date at all would be stored in the loaded transaction, which I suspect is even worse.
Comment 9 Christian Stimming 2013-06-18 20:11:19 UTC
With today's SVN trunk, the error seems to have disappeared: There is no crash. An imported posted-date from 1969-12-31 appears as a txn in the (old-style) register at that very date. Inserting the txn snippet from above in a gnucash file will simply give a gnucash file with this txn at 1969-12-31.

Hence some of the date parsing work in recent months seem to have fixed this. Can someone else please confirm this as well?
Comment 10 Geert Janssens 2013-06-20 19:51:26 UTC
My test system: Windows XP. I have created a small test file with one transaction dated 1969-12-30.

I first opened this test file in GnuCash 2.4.13. The date did get messed up in that version (as expected).

Next I opened the same file in today's nightly trunk build (2.5.2-2013-06-20). In this version the date appears just fine.

At least in the old register code. The new register code doesn't show the transaction at all. This however is a separated bug, unrelated to the date.

So I consider this one fixed. Thank you for pursuing this.
Comment 11 Christian Stimming 2013-06-20 20:06:37 UTC
Good. We don't know who fixed it over the last months or years, but at least it is fixed.
Comment 12 John Ralls 2018-06-29 22:00:55 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=514492. Please update any external references or bookmarks.