views:

208

answers:

3

I have a website that i've been working on for about a year now. Recently, it's started throwing System.AccessViolationException every now and then, in my dev machine, mostly, when I was away from the machine...

I haven't changed anything on the server code in weeks, since I've been working 100% on the Javascript part, and this error started appearing recently.

Also, the code I'm doing is 100% managed. I'm not doing any interop, calling strange DLLs, nothing. It's pure VB.Net, so I don't see how I could be generating one of these myself...

Now, I've been using this new machine for a couple of months, and it's not working 100% right. Every 2 or 3 days I'm getting a blue screen for example. I haven't had time to diagnose it properly, but I'm suspecting I may have a faulty RAM chip.

Is it possible that faulty RAM could lead to an AccessViolationException?
Or do I have an actual problem I should be looking into? (besides my RAM)


UPDATE:

I'm not really being able to find WHERE the error occurs, really.
I get the "unhandled exception, do you want to debug?" dialog, and when I attach the debugger, I have the Threads list, where I have all the ASP.Net threads, and 3 I create myself.
For these 3 I have a Call Stack , and they're all stopped at a Sleep() call (which is expectable).
For all the other threads, including the one that VS points to as the problem one, I have no Call Stack. I also have no details about the exception whatsoever.

So I don't know whether it happens every time in the same place or not.

As for memtest, yes, I'm going to do something like that, I'm just hoping to have SOME time to do it soon, but I wanted to know, in the meantime, whether this could explain this problem.


UPDATE 2:

Found this in the event log...

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)

Any ideas what to make of this?
Thanks
Daniel

+1  A: 

If you ever have doubts about faulty RAM, just run memtest86.

But if the error always happens in the same call, it's probably not RAM.

Ben S
Thanks! I don't really have any information about the exception. I just added more details to the question.
Daniel Magliola
+2  A: 

Is it possible that faulty RAM could lead to an AccessViolationException?

Yes this is possible. If the underlying memory of a process is not behaving predictably then yes it could lead to many different types of application faults including an AccessViolationException.

Is in likely that faulty RAM is leading to an AccessViolationException?

I would say it's much more likely that a fault in your program or library you call is at fault. The first step though is finding out why or more importantly where the AccessViolationException is occurring. Try attaching a debugger, break on AccessViolationExceptions and see what is actually happening.

Also Ben S's suggestion is a good one to rule out the RAM case fast.

JaredPar
Thanks for your answer! I would bet on the code 100% if it weren't for the fact that other stuff in this machine is not working perfectly either (like the blue screens I'm getting), and the fact that this is code that has worked for a looong time without any issues, and recently it's failing without me changing it at all...I also updated the question with more details, I can't really find where the exception is being thrown, at all...
Daniel Magliola
+1  A: 

Does this only happen on your dev machine? If yes then faulty RAM/hard disk (page file) is very possible. You may also want to reinstall the .NET Framework in case one of the libraries (perhaps one of the Native Image DLLs) has become corrupted.

Simply put:

If the error occurs in different sections of code each time, that's a good indicator that something's wrong with your system as a whole.

On the other hand, if the error repeatedly occurs in the same piece of code, then it's almost certainly that piece of code that's at fault.

As a previous answer noted, use Memtest86+ to confirm that your memory is good or not.

Ian Kemp
Yes, this only happens in my dev machine. As for where the error occurs, I have no idea, I just added more details about this to the question. Thanks for your help!
Daniel Magliola