Cannot profile a WCF service

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.
Post Reply
avorobjovs
Posts: 8
Joined: Thu Sep 12, 2013 4:54 pm

Cannot profile a WCF service

Post by avorobjovs » Thu Sep 12, 2013 5:07 pm

Hi all,

I have downloaded .NET Memory Profiler 4.6 Evaluation Version (4.6.52.0). I have Windows XP SP 3 and Visual Studio 2010 Ultimate SP1.
And now I trying to profile of my WCF service (C#, .NET Framework 4.0) using WebDev.Webserver.
But when the Profiler is loading my project and web application is appearing in a web browser I immediately have a fatal exception:
Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in 'C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\WebDev.WebServer40.EXE'.
Additional Information: The runtime has encountered a fatal error. The address of the error was at 0x79421a48, on thread 0xb8c. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
Only an "Attach to process" pattern works correctly.

How can I fix this problem?

Thank you in advance.
Alex

P.S. And also I have got a critical error when I downloaded the source of tutorial lessons (http://memprofiler.com/tutorials/), compiled a GemaOfLife application (in .NET 4.0), started to profile it and tried to collect a first snapshot.
The operation failed with the following error:
Profiling stopped unexpectedly when collecting snapshot.
And also only the "Attach to process" pattern works correctly.

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Re: Cannot profile a WCF service

Post by Andreas Suurkuusk » Sun Sep 15, 2013 9:21 pm

Profiling a WCF service is a bit complex, but profiling the GameOfLife application should be trivial for the profiler. That you cannot collect a snapshot from the GamOfLife application indicates some problem with your system.

Could you create log-files from the profiler and send them to support@scitech.se? Using the log-files, we will hopefully get some better information about why the profiling fails.

You can create log-files by using the command line below. This will create a set of log-files in the c:\MemProfilerLogs directory.

"C:\Program Files\SciTech\NetMemProfiler4\NetMemProfiler.exe" /log:c:\MemProfilerLogs
Best regards,

Andreas Suurkuusk
SciTech Software AB

avorobjovs
Posts: 8
Joined: Thu Sep 12, 2013 4:54 pm

Re: Cannot profile a WCF service

Post by avorobjovs » Mon Sep 16, 2013 6:34 pm

OK. I downloaded .NET Memory Profiler 4.6 Evaluation Version to the different machine with Windows 7. And I have the same result.

But I have found out that when I profile your built GameOfLife.exe in .NET 2.0 I receive a good memory snapshot in a second.

But when I open GameOfLife project in the Visual Studio 2010 and rebuild it with .NET 4.0 I have an exception when I try to get a snapshot.
Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in 'D:\Projects\GameOfLife\bin\Debug\GameOfLife.exe'.
Additional Information: The runtime has encountered a fatal error. The address of the error was at 0x7131d238, on thread 0x1660. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
Log files are sent to your mail.

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Re: Cannot profile a WCF service

Post by Andreas Suurkuusk » Tue Sep 17, 2013 6:12 pm

Thank you for the log-files. They don't contain any information about the actual exception that crashes the program, but they do indicate some very strange problems with the instance tracker, which most likely causes the crash when collecting a snapshot. We have spent a lot of time the last day trying to reproduce the crash, but still we have not succeeded. We have not tested with exactly the same runtime version as you use, since you are using a service branch of the runtime. You are using version 4.0.30319.2012 and we have run most tests using 4.0.30319.1008, but as far as I know these versions are identical.

Do you have any additional information about your system? How much memory do you have? How many processor cores? Have you made any changes to .NET runtime settings?
Best regards,

Andreas Suurkuusk
SciTech Software AB

avorobjovs
Posts: 8
Joined: Thu Sep 12, 2013 4:54 pm

Re: Cannot profile a WCF service

Post by avorobjovs » Tue Sep 17, 2013 10:34 pm

I downloaded the .NET Memory Profiler 4.6 Evaluation Version (version 4.6.52.0) from a page
http://memprofiler.com/download.aspx
using a link
http://cdn.memprofiler.com/download/Mem ... 4_6_52.exe

I downloaded the GameOfLife application from a page
http://memprofiler.com/tutorials/
using a link
http://cdn.memprofiler.com/tutorials/GameOfLife.zip

I have two different computers:

1. The first is a laptop. AMD A6-3400M processor. 4 Gb of RAM. Windows 7 Professional SP1 32-bit (English edition) (build 7601). Visual Studio 2010 Professional SP1 (version 10.0.40219.1). .NET Framework 4.0 (version 4.0.30319.2012 SP1).

2. The second is a virtual machine on a server. AMD Opteron processor. 3 Gb of RAM. Windows XP Professional SP3 32-bit (English edition) (build 2600.xpsp_sp3_gdr.100427-1636). Visual Studio 2010 Ultimate SP1 (version 10.0.40219.1). .NET Framework 4.0 (version 4.0.30319.225 SP1).

But a problem is the same on both computers.

I use the following scenario:
1. Extract a GameOfLife.zip archive.
2. Launch the .NET Memory Profiler, select "Profile application", select "...\GameOfLife\bin\Release\GameOfLife.exe", start GameOfLife application, select "New game" from a File menu, close game window, switch to the .NET Memory Profiler, collect snapshot, snapshot is collected successfully.
3. Launch the Visual Studio, open a GameOfLife solution, convert the solution using a conversion wizard, open GameOfLife project's properties, change a Target framework from 2.0 to 4.0, rebuild the project.
4. Launch the .NET Memory Profiler, select "Profile application", select "...\GameOfLife\bin\Debug\GameOfLife.exe", start GameOfLife application, select "New game" from a File menu, close game window, switch to the .NET Memory Profiler, receive an error.

If I launched the .NET Memory Profiler as a standalone application, a Just-In-Time Debugger window is open to propose to debug the GameOfLife.exe with a message
An unhandled Microsoft .NET Framework exception occurred in GameOfLife.exe [9432]
and when I closed this window I see a message in the .NET Memory Profiler
The operation failed with the following error:
Profiling stopped unexpectedly when collecting snapshot.
If I launched the integrated .NET Memory Profiler in the Visual Studio IDE, the Visual Studio shows an exception message
Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in 'D:\Projects\GameOfLife\bin\Debug\GameOfLife.exe'.
Additional Information: The runtime has encountered a fatal error. The address of the error was at 0x7131d238, on thread 0x1660. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
and when I closed this window I see a message in the .NET Memory Profiler
The operation failed with the following error:
Profiling stopped unexpectedly when collecting snapshot.
Right now I pay attention that I have the AMD processor in both cases. Maybe is it cause of the problem?

I think updated versions of .NET Framework (4.0.30319.2012 and 4.0.30319.225 in my cases) are installed by Visual Studio Service Pack 1.

avorobjovs
Posts: 8
Joined: Thu Sep 12, 2013 4:54 pm

Re: Cannot profile a WCF service

Post by avorobjovs » Tue Sep 17, 2013 11:33 pm

When I tried to profile a WCF Service on my Windows XP machine I use the following scenario:
1. Launch Visual Studio and build my WCF service application (.NET 4.0).
2. Launch the .NET Memory Profiler, select "Investigate memory leaks", select "ASP.NET application", select my WCF service options (Launch using WebDev.WebServer, version 4, web-site directory, virtual path and port), start profiling.
3. The WCF service is starting in a browser, but is not finished. A Just-In-Time Debugger window is open to propose to debug with a message
An unhandlel Microsoft .NET Framework exception occurred in WebDev.WebServer40.exe [6648]
and when I closed this window I see a message in the .NET Memory Profiler
The profiled process has been terminated.
Do you want to save profiler session?
When I launched the integrated .NET Memory Profiler in the Visual Studio IDE, the Visual Studio shows an exception message
Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in 'C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\WebDev.WebServer40.EXE'.
Additional Information: The runtime has encountered a fatal error. The address of the error was at 0x79421a48, on thread 0xb8c. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
I sent log files to your e-mail of this case too.

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Re: Cannot profile a WCF service

Post by Andreas Suurkuusk » Wed Sep 18, 2013 10:07 am

Thank you very much for the new log-files. I have still not been able to reproduce the error, but now I at least have a theory about what's happening. I have added some additional logging to the profiler and hopefully this will verify that my theory is correct. Can you download the latest build from http://cdn.memprofiler.com/download/Mem ... 4_6_53.exe and create a new set of log-files?

Thank you in advance.
Best regards,

Andreas Suurkuusk
SciTech Software AB

avorobjovs
Posts: 8
Joined: Thu Sep 12, 2013 4:54 pm

Re: Cannot profile a WCF service

Post by avorobjovs » Thu Sep 19, 2013 1:02 am

OK. I have created new log-files and sent you to e-mail.

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Re: Cannot profile a WCF service

Post by Andreas Suurkuusk » Thu Sep 19, 2013 3:06 pm

Thanks for the new log-files. As far as I can see, the error is not what I previously suspected. Instead it seems to be related to the library CryptoPro.Sharpei.CorLib. It gets loaded as the second assembly after mscorlib, before the executable assembly, so I assume that this library is somehow registered with the .NET runtime.

Directly after running the method "CryptoPro.Sharpei.NetDetours.NativeDetourEntryPoint.OnAssemblyLoadEvent", the instance tracker in the profiler starts reporting errors. Considering that the name of the method includes "detour", I assume that this library adds some low level hooks to the process. If this is the case, the hooks seem to conflict with the profiler callbacks.

I have not been able to find any information about the CryptoPro.Sharpei library, but could you try to disable it somehow and see if it works better.
Best regards,

Andreas Suurkuusk
SciTech Software AB

avorobjovs
Posts: 8
Joined: Thu Sep 12, 2013 4:54 pm

Re: Cannot profile a WCF service

Post by avorobjovs » Thu Sep 19, 2013 3:51 pm

OK. The CryptoPro.Sharpei.CorLib library is using in my WCF service. I will send you log from profiling of another WCF services that don't use CryptoPro.Sharpei.CorLib.

And what about of GameOfLife profiling error log? There isn't CryptoPro.Sharpei.CorLib library in the GameOfLife project.

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Re: Cannot profile a WCF service

Post by Andreas Suurkuusk » Fri Sep 20, 2013 11:59 am

Thanks for the new log-files. However, the CryptoPro.Sharpei.CorLib assembly is still loaded into the process. The thing is that the assembly gets loaded very early, before the application executable assembly has been loaded (just after loading mscorlib). This indicates that CryptoPro.Sharpei.CorLib is somehow being injected in all .NET processes on the system, regardless of whether it is referenced or not. Even in the GameOfLife application the CryptoPro.Sharpei.CorLib gets loaded, before the GameOfLife.exe assembly, and GameOfLife is definitely not using CryptoPro.Sharpei.CorLib.

If possible, I would suggest that you uninstall the CryptoPro.Sharpei library from your system and see if it works better.
Best regards,

Andreas Suurkuusk
SciTech Software AB

avorobjovs
Posts: 8
Joined: Thu Sep 12, 2013 4:54 pm

Re: Cannot profile a WCF service

Post by avorobjovs » Fri Sep 20, 2013 1:37 pm

Thank you very much, Andreas! I have uninstalled CryptoPro.Sharpei library on both machines and now the .NET Memory Profiler works properly and makes memory snapshots successfully!

But unfortunately an evaluation period of the .NET Memory Profiler will finished today. Can I to do somewhat to extend this period on other 7 days?

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Re: Cannot profile a WCF service

Post by Andreas Suurkuusk » Fri Sep 20, 2013 2:46 pm

I have sent a registration key to your e-mail that will give you a new 14-day evaluation of .NET Memory Profiler.
Best regards,

Andreas Suurkuusk
SciTech Software AB

avorobjovs
Posts: 8
Joined: Thu Sep 12, 2013 4:54 pm

Re: Cannot profile a WCF service

Post by avorobjovs » Fri Sep 20, 2013 4:32 pm

Thank you very much, Andreas!

Your Profiler is one of the best in the market! I wish you to continue to make it better and better. :)

Good luck!

Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests