-2

Most software creates a directory (usually in ~/Library or ~/Library/Application Support in MacOS) to store user preferences, browser history, etc. Most software attempts to create their data directory immediately upon launch and will either crash or refuse to continue if the directory cannot be created.

For example, if I create a file called ~/Library/Application Support/Google, then Google Chrome will be unable to access or create a directory there, because the name is already taken by a non directory. This will cause Google Chrome to immediately 'quit unexpectedly'. If I do the equivalent to Firefox, a message will say that an 'unexpected error has prevented changes from being saved' and will have to quit.

Why would changes have to be saved in software so importantly that the software will break if it cannot? Do they really need to create a bunch of files to render a webpage at a URL? I do not see any way were saving data is critical to the immediate execution of the app. The worst that should happen is all the apps configuration and data should reset as soon as it quits.

Why is it common for apps to break immediately if no data saving directory is available?

17
  • 1
    Thought experiment: how useful is a piece of software if it cannot save changes to its state? Commented Oct 20, 2021 at 17:13
  • 2
    @RobertHarvey If the software in question is a browser, as useful as a browser that is always in private or incognito mode
    – user403833
    Commented Oct 20, 2021 at 17:15
  • 1
    I think your real question is "How can I so easily break Chrome?" Commented Oct 20, 2021 at 17:16
  • 4
    In Chrome's specific case, the answer is most likely "if we can't even make our temporary folder available, something has gone horribly wrong, and we're giving up." Commented Oct 20, 2021 at 17:21
  • 2
    Because it is unexpected, and continuing to execute in that case can just create more problems. It could be indicative of a more serious problem, a security threat, a misconfiguration, or even a hardware problem. Any attempt to continue execution may work, may behave sporadically, crash out later (with an error that does not indicate the root problem), or even give some malicious process access to data it shouldn't have access to. Commented Oct 20, 2021 at 17:31

2 Answers 2

2

In C programming, we have this notion of undefined behavior.

It means that, if you write code that creates situations that are not defined by the language standard, anything can happen. The program could crash, it could corrupt memory, it could accidentally call fireMissiles(). Or, it could exhibit reasonable behavior. There's no way to be sure, once you enter the "undefined behavior" space.

Hence, the simple assumption that a program usually makes that it can access the disk, not an unreasonable assumption in most cases. Most programs will give up if the computer they're running on cannot meet this simple requirement. Continuing to run a program when a machine has been perceived to be compromised in some way can cause all sorts of unforseen problems.

Chrome doesn't make the guarantee that it doesn't save any kind of state at all in incognito mode. It only makes certain assertions about your privacy. Remembering the window location when you close the program doesn't have anything to do with your privacy, and I'm sure there are other examples that I haven't thought of.

-3

I believe that the "quit unexpectedly" behavior that you see is caused by an "unhandled exception." Many (non-web ...) programming contexts will also do this if an exception drifts all the way to the top without being caught.

Unfortunately, lots of developers write their software on "super-powerful machines," where "nothing ever goes wrong," and issues like these literally never occur to them. They don't mean it ...


Which is, for example, why I counsel mobile developers to go buy a mobile phone in the checkout-line of their supermarket, and to make sure that their precious application will actually run on that, instead of their "IPhone 135 with 65,536GB of memory."

4
  • 2
    Well, sure, but could Google have anticipated that someone would change their Application Support folder to a file? Google has very talented people working for them, but I'm pretty sure none of them are clairvoyant. Commented Oct 20, 2021 at 20:23
  • 1
    @RobertHarvey Testing the return value of the functions used to access the Application Support folder would exhaustively handle errors, including my putting a file there, and then they should handle the error gracefully like alerting the user that changes will not be saved instead of just letting the app crash
    – user403833
    Commented Oct 20, 2021 at 20:31
  • @user16217248 You assume that the directory is only used for user configuration purposes. You assume that terminating the program is not graceful. You even seem to assume that terminating the program is unintentional, which very well might be. I think your question is interesting, but it stems from the incorrect premise that a program should never be terminated and should handle all possible edge cases at all cost, which just doesn't work in practice. Commented Oct 21, 2021 at 11:08
  • @user16217248 There are user errors in the category "You've broken your Mac". If you do that, my app will show an alert if you're lucky and exit, but fixing it is your problem. Take your Mac to your admin or to an Apple Store or to your nephew who is good with computers, but not to me. The whole Library folder is hidden. If you go into hidden folders, you're on your own.
    – gnasher729
    Commented Oct 21, 2021 at 14:32