iTunes intermittent freeze/crash: how can I diagnose the problem? I have an ongoing but intermittent problem with iTunes. Sometimes after starting iTunes or after plugging in an iPhone, iTunes will cause my Mac to become unresponsive. I'm having trouble reproducing this problem, and it doesn't seem to leave any traces in the system log. How can I figure out what's causing this problem?

Here are the symptoms: When I start iTunes, it loads and appears to be functioning normally for a few seconds, but then my Mac becomes unresponsive. The trackpad still moves the on-screen pointer, but input, as far as I can tell, is completely ignored. 

Doesn't work:


Attempting to quit or force-quit. Nothing happens: keyboard input ignored.
Clicking on anything: clicks are ignored.
Removing the iPhone, when the freeze happens after plugging in the iPhone - the system does not react to the removal of the device, and it still appears in the iTunes sidebar.


Interesting features:


Mouse/cursor still moves, but clicks just "vanish" - nothing happens on click.
If music or other media are still playing, they continue to play - sometimes to the end of the current track, sometimes for less (long tracks). 
If an external monitor is in use when the freeze happens, and is unplugged after the freeze, the Mac doesn't do the fade-to-blue-and-redraw thing. It doesn't react to the monitor going away. 


What I've tried:


Removing iTunes library and rebuilding from the XML file does not fix the issue. 
Making sure that I'm the owner of all of the relevant iTunes files (single-user computer) - no change.
Restarting computer: the problem never appears on the first launch of iTunes after a restart. 


What puzzles me: 


Sometimes it happens with just iTunes, sometimes it happens with the iTunes + plugged-in iPhone combination. 
Why is mouse movement still visible even though the rest of the system has gone utterly brain-dead?
Why is there nothing in the system logs that I've been able to see?


Setup details:


Early 2011 Macbook Pro, Snow Leopard 10.6.8.
iTunes 10.6.3
iPhone 4, iOS 5.1.1
Music folder on an external hard drive (a few hundred gigs of music in the library, and the onboard hard drive is an 128GB SSD, so this is non-negotiable)


Currently, when I run into this problem, I have to reboot by holding down the power button until the Mac powers down, then start it again. This is deeply sub-optimal. Is this a known problem in disguise with a known fix? If not, how can I narrow down the problem, how I can I get more information about what's actually happening during the crash? The nature of the problem means that no crash report is generated, so that's a difficulty. I've tried watching top, ps, and lsof whilst trying to reproduce the problem, but since I don't know what I'm looking for, I can't really get any help from the information they provide.
I would simply say that your Library is corrupt for some reason. As your library is a virtual reference lookup to your actual music files, if it has a problem it is possible that it will either give you issues at program startup or perhaps when you add something to your library as it will read the reference file and encounter issues when trying to add to it.

I first of all tried all the obvious, Disk Utility repair, permissions, deleted and reloaded iTunes, etc. However all of that will still use the original Library file so it won't solve the issues so many are having with iTunes.

The simplest yet time related route is to rebuild your library. What this means is that you need to create a new one, and import all your content again. It may take you 30 minutes and for your computer 10 hours.

As it's your library that's corrupt and not the actual files/file structure that is the problem you will be able to import all of your music again together. About 95% of your albums will be kept together although in some occasions with downloaded albums their reference name will not match that of the official release so it may be separated and in need of the artwork but neither is a big take to sort out. It's the same deal with your movies.


Quit iTunes
Hold Alt and click iTunes again
Select new Library (don't worry your old one is still there and will not be deleted)
Then you can start to rebuild. You can always go back to your old Library by closing iTunes, holding Alt and clicking on iTunes.


To select which library to open - you will see that in your Music/Itunes folder there are now two libraries and the xml library file is in the sub folder for each for you to select if you cant find it. Give yours a simple name when you create it such as 'ITunes Library 2' that way you can search for it too if you can't find it.

The only issue with this method is having to backup your iPhone/iPad or other device in your old Library as it can only be sync'd with one library. However, once you are happy with your new library you can Erase your device and sync it with your new Library.

When you erase your iPhone for example, it will only wipe/erase the content (Music, Movies, etc.) it will not delete Apps, Messages, Bookmarks, Photos, etc.

I hope this helps, as it not only sorted my iTunes issues for good but also made my iMac a lot faster in general as iTunes is not struggling and does not crash any more.