Why does software crash, freeze and hang?

Discussion in 'Mac Apps and Mac App Store' started by dahacouk, Nov 9, 2005.

  1. dahacouk macrumors member


    May 24, 2004
    Dartmoor, Devon, UK
    Hands up who has never had a desktop application fatally crash, temporarily freeze or permanently hang on them? Apart from the abacus users over there we've all had it happen to us. But why?

    Is it just sloppy programming or is there something fundamentally broken with the way applications and operating systems are coded?

    After upgrading to OS X 10.4.3, Mail started consistently crashing a few seconds after launching. After digging around the forums I got a possible fix: remove all stored email messages and configuration/preference files. It worked, I'm happy to say. I got a virgin Mail application that was seemingly stable. Luckily, I use IMAP email - all my mail is stored on my server. So, after setting up the account details in Mail - yet again - I just synced Mail with the IMAP server and I had all my email local again - nice.

    Now then, this debacle isn't new. I've had to do this all before. There's a pattern here perhaps. When the chips are down or when configuration files are corrupted or not understood by the new version of the software why does the application have to crash on me? Why is this such a fragile world?

    What's the basis for my thinking that our software could be build to not crash, freeze or hang? I'll tell you...

    Take the scenario where you're browsing the Web, hopping from one website to another - and then you click on a link to a website that doesn't exist. How do you know? Well, the browser says "can't find website" or some such thing. It doesn't crash, freeze or throw a wobbly - hopefully.

    Now, what's special about the browser is that it is generally robust enough not to crash when it comes across websites that don't exist or don't adhere to 100% HTML standard specifications - hopefully. In fact there's a lot of expectation that websites wont exist or wont conform to web standards built into the browser.

    Now, what would happen if Mail found that it's configuration files where corrupt or formatted wrong or of an old version? Could it just say "can't read configuration files - shall I try to repair or just set up a brand new one?" rather than just crashing all forlorn like? Flump! I know Mail is currently capable of setting up a new configuration file because that's what it did when I removed them.

    What would happen if Mail was to pretty much expect configuration files not to conform to standard (like the web browser and its websites)? If rather than crashing Mail just asked politely "old preference files not readable - would you like to start afresh?" Wouldn't that be much nicer?

    And another thing... What about that spinning coloured ball or watch (for pre OS X users) or sand timer (for Windows users), eh? That long pause. Why is my interface frozen when the application is waiting for data or running a calculation? That just seems archaic. A good (or bad) case in point is spotlight searches. Why does Finder freeze with that spinning ball when it does a spotlight search? And why can't I open any other Finder windows when it freezes?

    So, something seems wrong at the core here. Spinning balls shouldn't exist. So, what we could be talking here is decoupling the desktop interface from the collection and management of the data. So that the interface never crashes or stalls but could report if it's not finding the data where or in the form it thinks it should find it. And the interface never momentarily freezes when accessing information or performing a calculation, it just displays a time line bar and lets you get on with other stuff.

    Wouldn't this be much better - much more robust? Applications would be built to handle corrupt, malformed or missing data gracefully and also handle waiting for data to sync up by showing the user what's going on. And never crash or hang the user interface.

    Developers could split the interface from the data processing part of their applications and enable these two components to message each other. Or an application could be split into many more components all messaging each other. The contents of each message would be checked before ingesting so that it couldn't hang or crash the recipient component.

    I must admit that sometimes applications seem to cope well but there just seems to be far too many times when they don't.

    Now, am I dreaming or is there fundamentally something amiss in the way applications and operating systems are built today? Couldn't all this be much better? What do you reckon, eh?

    Cheers Daniel
  2. Lacero macrumors 604


    Jan 20, 2005
    Sounds like something is wrong with your system. Flakey RAM or a failing HD would be my guesses.

    Spotlight searches should not bring up beachballs. As for Finder freezes, that still occurs on occasion but normally only happens when a remote connection has dropped.
  3. mad jew Moderator emeritus

    mad jew

    Apr 3, 2004
    Adelaide, Australia
    I don't quite think it's fair comparing all browsers to a single email client. From my experience, I actually find that Mail has been 100% reliable for me so far yet I can't say the same about Safari (three crashes).

    Also, I agree with the infallible Lacero in that it sounds like something's not quite right with your system. It might be hardware related, as stipulated, or it may be a software conflict (how ironic). Have you got an hacks or theme changers or anything quirky installed? :)
  4. yenko macrumors 6502a

    Aug 29, 2005
    The simplest thing to do after the 10.4.3 update (or any update for that matter) is to repair permissions and restart.

    Maybe a couple of times......doesn't hurt.:p
  5. dahacouk thread starter macrumors member


    May 24, 2004
    Dartmoor, Devon, UK
    How do I check for bad RAM or bad HD?

    Other than get new RAM and HD I mean.

    Any utilities I can run?

    But then again I'm upgrading to a Quad Mac in the next few months! ;-)

    But still I'd like to check that whoever gets my Mac isn't going to get a bad one.

    Cheers Daniel
  6. GorillaPaws macrumors 6502a


    Oct 26, 2003
    Richmond, VA
    He may have hardware issues, but I don't think that's the main point of his post. I used to wonder the same thing, but I've recently started dabbling (emphasis on dabble), in basic coca programming. What I've gleaned from this is that there are so many potential sources for problems when creating an app that it'd be virtually impossible to anticipate and create a safeguard for every possible potential error. That's why they have beta testing. They do the best they can to anticipate as much as they can, but there are things they didn't think of and when beta testers experience errors they go back and fix the problem (trouble is, even beta testers don't catch everything so some of it gets passed on to the final user). I'm still very much a beginner at this, so I could be totally off; feel free to correct me.

    As far as the UI being seperate from the actual computer's processes, I'm not smart enough to speak to that, but I'm fairly confident that it would require a total reworking of the Kernel and how the GUI is managed (a MASSIVE undertaking for a somewhat marginal benefit -- not gettting the spinning beachball when an app's frozen which happens rarely?). Besides the beachball is a form of feedback that lets the user know there's a problem w/ that app. Don't get me wrong, it annoys the hell out of me too, but I just don't see the benefits outweighing the costs involved. As for why they didn't implement this initially (which may be a better question), I'm not smart enough to answer this but there's likely a very good, and very techincal answer.

    Edit: oh and to answer your question. Run the Harware Test CD that came with your Mac. It'll take a while and I'm told isn't 100% accurate, but It's a good first step.
  7. caveman_uk Guest


    Feb 17, 2003
    Hitchin, Herts, UK
    Strangely enough I've found the opposite - for me Mail is very stable and Safari occasionally crashes. Nothing that's ever worried me though

    A lot of software is written that way. In Cocoa programming the main paradigm used is Model-View-Controller which separates the 'data' from the way it's represented to the user. Some languages also encourage encapsulation of function in things called objects which 'message' each other as you describe. Apps written this way still crash if something happens the programmer didn't expect or allow for.

    Edit: fixed spelling caused by errant fingers.

Share This Page