I did a bit more digging and the error is occuring within the code behind for the CMSWebParts\CommunityServices\SocialBookmarking.ascx web part. I have turned on debugging in the web.config file, so that the next time it crashes, I will be able to see exactly which line number is causing the crash.
However, ever since I've switched debugging on, it has not crashed. Weird.
On a side note, I reviewed the code in the user control, and I did not see any obvious mistakes in the code that would cause the bug. However, the one thing that I do notice is that the data is stored in a static hashtable that will be shared by all threads, and access to that shared resource is not synchronized. This could cause the hashtable to become corrupted during initialization.
To fix this potential problem a lock statement can be added that surrounds the initialization code in the FillHashTable() method (to ensure that two threads don't simulataneously initialize the data):
private static void FillHashTable()
{
lock (bookmarkServices.SyncRoot)
{
if (bookmarkServices.Count == 0)
{
// Each record has display name, url, url to book and title
bookmarkServices["GoogleBookmarks"] = new string[] { "Google Bookmarks", "http://www.google.com/bookmarks/mark?op=add&bkmk=", "&title=" };
/* .... etc. */
}
}
}
The lack of a lock here may actually be the cause of the crash, since two threads adding things to the hashtable at the same time could cause its state to get corrupted.