Saved application states and Office 2011 EXC_BAD_ACCESS application crashes
I had an interesting issue crop up yesterday. One of our users sent in a ticket to report that Word 2011 on her laptop kept crashing with an EXC_BAD_ACCESS error. None of her other Office 2011 applications were exhibiting the behavior; it was specific to Word 2011.
When this error has cropped up in the past, I’ve fixed it in the past by removing Word’s Normal.dotm template from /Users/username/Library/Application Support/Microsoft/Office/User Templates or removing the com.microsoft preference files for the affected application from /Users/username/Library/Preferences.
So this time, I moved the following files to a new folder that I created on the user’s desktop:
/Users/username/Library/Application Support/Microsoft/Office/User Templates/Normal.dotm /Users/username/Library/Preferences/com.microsoft.Word.plist
Then I logged the user out, asked them to log back in and had them relaunch Word. Crash. EXC_BAD_ACCESS error again. This was going to be an unusual one…
I double-checked to make sure that both the files I had moved had not recreated themselves. They hadn’t, Word had crashed before being able to detect that those files were not there.
I then spent the next hour doing the following:
1. Logging in as my local administrator to confirm that issue seemed to be confined to the user’s account.
Result: Word launched fine and without errors while logged in from the local admin.
2. Moving all of the various com.microsoft preference files and the Microsoft folder from /Users/username/Library/Preferences to the folder I had set up on the Desktop.
Result: Crash. EXC_BAD_ACCESS error.
3. Renaming /Users/username/Library/Application Support/Microsoft to /Users/username/Library/Application Support/Microsoft_backup to force the OS to create a new /Users/username/Library/Application Support/Microsoft folder with default settings.
Result: Crash. EXC_BAD_ACCESS error.
4. Booting from a NetBoot utility disk and clearing the contents of the following cache folders on the user’s boot drive:
/var/folders /Library/Caches /System/Library/Caches /Users/username/Library/Caches
5. While still booted from the utility NetBoot, running DiskWarrior and a permissions repair on the user’s boot drive to make sure all my bases were covered.
After rebooting from NetBoot back to the user’s boot drive, I asked my user to log in again and relaunch Word. Crash. EXC_BAD_ACCESS error again. But this time, I caught a small “opening file” screen that was gone in an eyeblink because Word crashed immediately after the screen appeared. Word had been trying to open a file. Why? How? All the work I had done should have cleared out Word’s listing of recent files.
I stopped at that point and just thought through the process for a minute or so. Then I went into /Users/username/Library/Saved Application State and moved the com.microsoft.Word.savedState folder to the folder on the user’s desktop where I had been storing the other files that I had moved. After that, Word launched without a single error.
What had happened?
My user had been editing a file when Word initially crashed. When I asked her to open the file in question, Word instantly crashed with an EXC_BAD_ACCESS error. In the initial crash, the file had somehow corrupted.
After that, Word got trapped in a cycle. When Word launched, it queried the saved state which told it to open this file. When Word tried to open the file, it crashed instantly. On restart, it queried the saved state again. Saved state told it to open this file; CRASH. The only way to break out of the cycle was to get the saved state out of the loop, which allowed Word to launch without trying to open the corrupted file.
Fortunately, the document in this case was a file that the user had received that day via email from a colleague. They were able to recover the original file from her email and were able to save and edit the new copy of the document without Word crashing.
Saved states aren’t unique to Microsoft applications and any application on OS X that’s been updated to support saved states may also exhibit this behavior. If you see an application repeatedly behaving oddly on launch, try moving the corresponding saved state folder out of /Users/username/Library/Saved Application State and see if the behavior clears up.