Profiling ASP.NET MVC Memory Access Exception

Code profiling for .NET Developers

Moderators: Luke Jefferson, StephenC, Alex.Davies, AndrewH, melvyn.harbour, Laura Morley

Profiling ASP.NET MVC Memory Access Exception

Postby IvanL » Fri Nov 26, 2010 11:44 am

I'm running ANTS Performance Profiler 6.1.0.119 and wished to profile an ASP.NET MVC website (MVC2). But as soon as I start up the profiler I get the following exception:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.]
System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +48
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +275
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +139
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +47

[ConfigurationErrorsException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +601
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +193
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +45
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +56
System.Web.Compilation.CodeDirectoryCompiler.GetCodeDirectoryAssembly(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories, Boolean isDirectoryAllowed) +601
System.Web.Compilation.BuildManager.CompileCodeDirectory(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories) +185
System.Web.Compilation.BuildManager.CompileResourcesDirectory() +30
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +375

[HttpException (0x80004005): Attempted to read or write protected memory. This is often an indication that other memory is corrupt.]
System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +60
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +506
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +768

[HttpException (0x80004005): Attempted to read or write protected memory. This is often an indication that other memory is corrupt.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +547
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +78
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +258




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955


As options I used \"Line level and method level; only with source code\", \"Record SQL and IO\" and the \"Profile child processes\" is on.

The last line of code that is visible and most likely where the profiler does something fishy is when MVC executes the following: AreaRegistration.RegisterAllAreas();

If I try to start profiling again after this occurred the IE just opens and remains waiting for reply without anything happening, there's no processor time besides the initial startup so it appears as if everything broke and the site refuses to load. If I run it outside the profiler it works just fine however.
IvanL
 
Posts: 1
Joined: Fri Nov 26, 2010 11:18 am
Location: Belgium

Postby nick.maidment » Fri Nov 26, 2010 12:13 pm

There are a couple of things you can try to get this working. First, switch the profiling mode from "line level" to "method level".

Second, remove any pdbs you have. If it works after this, you just need to work out which pdb is causing the problem.

If it still doesn't work after trying these. We'll need to analyse a memory dump (using a debugger like windbg) to work out exactly what the problem is.
nick.maidment
 
Posts: 74
Joined: Fri Jan 29, 2010 1:55 pm

Postby lmdarif » Thu Mar 03, 2011 7:53 am

Any update on this issue, i am facing this issue on NON MVC asp.net application.

Thanks
lmdarif
 
Posts: 1
Joined: Thu Mar 03, 2011 7:50 am


Return to ANTS Performance Profiler 6

Who is online

Users browsing this forum: No registered users and 0 guests