This is kind of repeated from my previous question, although the objective of my question is completely different now.
I'm getting, now and then, about once a week, only in my development machine, a System.AccessViolationException in a web app I made.
Since my machine is having a few things that don't work quite well (like a blue screen every now and then), I assumed before it might be faulty RAM. After 24 hours running memtest, i'm pretty sure it's not...
So, this is the situation: This is a wep App, VB.Net 2.0, 100% managed code, doesn't use COM, Interop, or anything like that. It's running on a Windows Server 2008 SP2 box.
The only "strange" thing I'm doing is starting 3 threads of my own when the app starts, that do "cron like" stuff inside the appdomain, and also most of the requests this app is handling are handled asynchronously, and many of them are held open without a response for up to 30 seconds. (I'm doing Comet long-polling).
Also, i've been working on this code for about a year now, and it's only started to do this about a month ago. I can't think of anything major or important that I changed on this whole web app that I changed lately. I've been working almost fully on the Javascript frontend.
When the exception happens, I get the typical popup asking me whether I want to debug.
When I do, I see all the ASP.Net threads plus my 3 threads.
My 3 threads are in a call to Sleep(), which is normal. All the other ASP.Net threads have no call stack at all.
In the thread where Visual Studio tells me I got the exception, I don't see anything.
So I don't know for sure where the error happens, or even whether it happens every time in the same place or not.
All I could find as a clue is this in the "Application" event log:
Faulting application w3wp.exe, version 7.0.6002.18005, time stamp 0x49e03238,
faulting module unknown, version 0.0.0.0, time stamp 0x00000000, exception code
0xc0000005, fault offset 0x0000000002358fe8, process id 0x1f4c, application
start time 0x01ca41395c564ed9.
And right after that, another event with this:
An unhandled exception occurred and the process was terminated.
Application ID: DefaultDomain
Process ID: 6632
Exception: System.AccessViolationException
Message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
StackTrace: at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
I've googled MgdIndicateCompletion , but couldn't find anything really useful...
One thing that HAS changed about a month ago, now that I think of it, is that I moved from Server 2003 x86 to Server 2008 x64 (and thus, IIS6 to IIS7) in my dev machine. Maybe that's the cause, but still, i'm not sure what to make of this...
I mean, this would place the problem completely out of my codebase, right?
UPDATE: As suggested here, turning the App Pool integration to "Classic" seems to fix it. I'm still looking for a decent solution, or at least an explanation, though.