Well, I might have found the answer. Over at MacOSXHints forums someone had the same problem. Another person replied that it had to do with Virex 7.5 and automatic checking. That makes sense, since Virex could theoretically prevent iTunes from saving to its library file if Virex was scanning it at the time. That would also explain the sporadic nature of the error.
So at this point I've disabled "Background Virus Checking". Time will tell if that's the fix.