Anatomy of a Crash (Jan 10)

Goldenseal accounting software rarely crashes, thanks to lots and lots of sanity-checking code. If something isn’t kosher, it gives an error message with the exact source code line that failed. That makes it easy for us to find and fix the bug. Then it exits to the event loop, so you can keep working.

The approach works well, but it does have a cost. Of the 26 megabytes in the Goldenseal app, almost half is just text for error messages. 99% of them will never be triggered, but it’s worth the weight to get quick fixes for the naughty 1%.

Programming the new accounting software works the same way. We rarely see crashes: just error messages and things that don’t work right. However, this week there was an actual crash. It happened after using the Link button to see the bank transaction that pays for a purchase. The dialog worked OK, but the app crashed later.

The bug turned out to be a dangling pointer in the bank transaction. We can’t test for those, so we must never let them dangle.

The accounting app has to keep track of which records are visible, so the screen will update if one is changed remotely. For example, changing payment status also changes the purchase status. In Goldenseal, each record keeps a pointer to the viewer it’s in (or null if not visible). When we post to the record, its viewer is also reloaded (if it exists).

The code is efficient, but a design flaw. A risky way to do the job. This wasn’t the first time the app has crashed there. Rather than slap on a quick fix, we decided to scrub it clean. The new app now checks every tab and window to see if the record is showing. No need for a pointer at all. It’s slower, but only by microseconds.

During the rewrite, a couple other possible bugs turned up, deep in the guts. To fix those, we need to understand the old code better. That means running current Goldenseal in the debugger, to make sure the new app does the same things at the same times. Linking records to the screen is complicated.

Setting up an old machine to run version 4.96 was a challenge. Because of the tough real estate market, TurtleSoft was in two temporary offices in 2023, plus the original and the new. Many chances for important stuff to be tucked away in a miscellaneous box. Some are still unopened.

We finally found an older Mac Mini with proper setup, plus all the wiring and converters it needs. Weather sucks, so app development is moving right along.

Dennis Kolva
Programming Director
TurtleSoft.com

Author: Dennis Kolva

Programming Director for Turtle Creek Software. Design & planning of accounting and estimating software.