Sandboxed applications 'crashing' in OS X upon location change
Though OS X generates a crash report, the programs do not crash at all and continue to work just fine.
An apparent bug is present in OS X 10.7 "Lion" that causes some applications to crash when the system's network location configuration is changed. However, while the system generates a crash report, the applications appear to have not crashed at all.
This issue happens because of a bug with how OS X handles both network location configurations and its process sandboxing routines.
In OS X you can set up different "locations" in the Network system preferences -- convenient configurations for the various network setups you might need for your work. For instance, a home Wi-Fi setup might be set for automatic IP configuration with DHCP, but at work you might need to set this manually. The location settings allow you to have these two configurations and switch between them easily. To do this, go in the Network system preferences, choose Edit from the Location menu, and then duplicate or create a location. Then alter its settings as needed for your configuration.
When the new locations are configured, a Locations menu that contains their names will appear; it can be used to quickly change the network configuration to match your working environment.
This feature is convenient, but if you switch locations using this menu in Lion, certain applications such as TextEdit or Preview may crash if they are the foremost applications. However, while the system will generate a crash report that mentions the program has crashed, it clearly is still running normally and none of its contents appears to be affected.
Apple Discussion member "bbenny" created an excellent demonstration of this problem in a YouTube video:
Furthermore, when this happens, the network location does not change and instead remains at its previous setting. Additional attempts to change the network location will result in the same crash report behavior, as long as either TextEdit or Preview are the foremost application. If you bring another program to the forefront such as the Finder, the network locations will change successfully, even if TextEdit and Preview have remained open in the background.
In more recent versions of the OS, Apple has incorporated sandboxing techniques to better isolate running processes from each other and only allow them access to the resources they need. This is a security measure to help keep systems stable if a program is buggy or is hacked, and both TextEdit and Preview are a couple of the programs that Apple has sandboxed in OS X. This suggests that the problem here is with the sandboxing rules in OS X, and how they are handling the network configuration change that is invoked from within these programs.
When the network change happens, it appears that it is attempting to spawn another instance of the TextEdit or Preview appliations as a child process of the main program instance, which then crashes and displays the crash report. This then halts the network location change.
Because this is likely a problem with the sandboxing routines in OS X, Apple will need to address with an update; however, the bug does not appear to affect any of the running programs in any adverse ways. The system is simply starting a new and unneeded process in a way that causes it to crash.
The only drawback to this issue is that the desired network settings do not get changed; however, because this issue only happens if the sandboxed applications are in the forefront, you can switch to a different application (such as the Finder) and then change your network location settings.