Money Sunset Import Bug Remediation

From PalOMoney
Jump to navigation Jump to search

Introduction

PalOMoney version 1.0.5 release candidate build 893 was being tested with Money Sunset on a 64 bit Windows 7 machine. While testing the Statement view Update Now function, it downloaded about a dozen statements, each time calling the (annoying) Money Shell Handler to queue them for processing in Money. After 12 Ok clicks, the downloaded and log files were examined and found to be Ok. However, when Money Sunset was launched, it crashed after a few seconds.

PalOMoney was used to repair the Money file outside of Money. Money was launched again, and suffered another crash. There was no way to prevent a crash. However, the Money file worked fine on another machine. After renaming the Money file, and opening an older file, the crash still occurred. The Money Sunset environment itself had become unstable.

This was not an auspicious beginning for PalOMoney version 1.0.5 release candidate build 893, and delayed the release of 1.0.5 pending a resolution of this issue. Ordinary users cannot tolerate this kind of performance.

Later, after some research (below), the Money Sunset environment was fixed, and Money retested. Money would always crash when importing an OFX file from a certain financial institution, regardless of the import method (shell handler or File | Import). The OFX file in question was examined and found to be valid and correct. Applying the known defect patch (below) did not resolve the crash.

This topic also has a blog entry version.

Research

It wasn't really a problem with PalOMoney. There is a known problem importing ofx files into Money. Referring to Microsoft's Raymond Chen's Microsoft Money crashes during import of account ... - MSDN Blogs and windows-8-64-bit-version-compatibility-with-sunset-money/. The 4 byte patch in the articles was applied, but Money still crashed. More research turns up MS Money Sunset+Windows 8, Crash when adding new Payee which has a similar problem.

In order for Microsoft Money Sunset to be viable for ongoing use, it will require patches to fix bugs possibly introduced when downgrading Money 2008 to produce Sunset. This task has been (reluctantly) added to the PalOMoney project, but it adds the task of reverse engineering to the project.

Reverse Engineering to Correct Bugs

In the words of commenter to Chen's blog entry above, "Reverse-engineering is a violation of the Microsoft Money EULA...," and PalOMoney.com does not want to run afoul of that issue. Another commenter wrote that "There are certain court rulings about warranty of merchantability that override the EULA in situations like this one." Although this comment is not a duly prepared legal memorandum that can be relied upon safely, PalOMoney.com has done the necessary examination and identified a bug and has developed workarounds and remediation.

Any readers with insight into this issue are encouraged to add it to the wiki topic or discussion, blog comments, or discuss it in the forums.

OFX Crash Bug Cause

The fault occurs when doing a string compare on uninitialized memory.

Apparently, the bug is caused several functions up the call stack by failing to initialize in all circumstances what seems to be an in-memory hash table. The initialization occurs in two phases. First the table is initialized with zeros to indicate no entries. Then an entry is made into the table. Each phase tests a pointer in a large object supplied by the calling function, and either skips or performs the initialization. When the system crashes, the first test skips the initialization. A call to the hash table find function then calls string compare on an entry in the uninitialized hash table, which causes the fault.

The crash occurs with OFX downloads from certain accounts at certain financial institutions. However, not all downloads of those accounts cause a crash. The cause of this is being investigated and will be reported here as answers are discovered.

Money Sunset crashes when processing the "Import Files" queue. This queue is not part of the Money file, so it will cause a crash when opening any Money file on that machine.

As Raymond Chen wrote, skipping string (here, hash table) initialization may not cause problems if all the memory in question contains zeros and/or references to readable memory, so users so far have been lucky. But often that luck runs out under Windows 7 or 8 in his case, and also in our testing. Legacy Money users may not have encountered this error yet because not using Windows 7 or 8, plus possibly other yet unknown factors (including good luck?).

The "Payee Change" crash mentioned in the above blogs has not been investigated. It may be caused by the same problem.

OFX Crash Bug Workarounds

One workaround is to not import transactions from problem accounts at problem institutions, or to import them using Money's File Import, and NOT by double clicking them and NOT using the Shell Open method to process downloads via PalOMoney, both of which add the downloads to the Import Files queue. However, this does not help very much when a user's Money Sunset installation is unstable. So the first thing to do is to fix the installation, below.

The Money file is left with open objects by Money crashing. This is fixed either by opening it with Money (which repairs with a "Working..." progress bar, or by running the the PalOMoney File | Repair | Repair function.

The "Import Files" queue is saved in the registry under [HKEY_CURRENT_USER\Software\Microsoft\Money\17.0] "Import Files" key. The MULTI_SZ value contains the names of temporary files copied by the Money shell handler. The key is deleted (not there) when the queue is empty.

You can just delete the key, but PalOMoney adventuresome explorers are encouraged to rename the entry instead of deleting it.

  • Open RegEdit. You may not need administrative privilege to access HKCU. Try it. If you do, run RegEdit as administrator.
  • Locate the "Import Files" key, and press F2 to edit the key name.
  • Add a space and "00", "01", etc. to the key name (e.g., "Import Files 02").

This leaves the files in your TEMP folder (e.g., \users\UserName\AppDate\Local\Temp), which are names with a "~of" plus a random number then .tmp (e.g, ~of896.tmp). You can ignore them for now, and use them for testing the remediation, below.

PalOMoney is being enhanced to include these functions. Also, PalOMoney will offer a direct queue import method, which write to the registry key directly, bypassing the annoying Money Shell Handler with its "Launch Money Now?" nagging.

Finally, the investigation into why some downloads crash and others don't continues, and may result in PalOMoney being able to "filter" a download to add required or remove problematic OFX entries to prevent the crash in the first place. However, this would not fix the general problem of crashing when importing or changing payee names, etc. mentioned in the blog posts above.

OFX Crash Bug Remediation

The Money Sunset software can be patched to eliminate the first test that skips the hash table initialization by replacing the test and jump with NOPs (we regret not having a more elegant solution). The PalOMoney app cannot perform this function, because patching a program file requires elevated administrator privileges, and it is undesirable to run PalOMoney or any ordinary application with elevated privileges.

PalOMoney developed and has released a free Money Sunset Patch Utility named PatchOMoney for download without charge.

PatchOMoney is a simple console (command prompt) program that scans the affected Money program file(s) for unpatched and patched instructions, and offers the user the choice of either patching the file to eliminate the defects, or unpatching the file to restore the original functions and bugs. PatchOMoney first applies (or removes) Chen's patch, then the new patch. The utility also backs up the original file(s). The utility requires administrator elevation, or changing permissions on the Money program files folder, to run. The Money Sunset software is apparently not under Windows file protection, so the changes will not revert automatically to an earlier version.