Performance profiler - System.InvalidProgramException
deadlyviper
Posts: 6
Hi,
When I profile my application with the performance profiler, it consistantly fails with a System.InvalidProgramException.
I've searched around for this on Google, and various articles suggest that it is related to bad MSIL. The same application works perfectly well under the memory profiler, and opened directly (as console app).
The crash log gives the error below (I've blanked out the company in the namespace)
Event Type: Error
Event Source: .NET Runtime 2.0 Error Reporting
Event Category: None
Event ID: 5000
Date: 31/08/2006
Time: 15:08:25
User: N/A
Computer: MYPC
Description:
EventType clr20r3, P1 utimydz5wtxl4ptvworcggqxpuyxbisk, P2 1.0.0.0, P3 44f6ed23, P4 companyx.messaging.channels, P5 1.0.0.0, P6 44f6ed19, P7 7e, P8 3e, P9 system.invalidprogramexception, P10 NIL.
My own exception handler captures the following:
Event Type: Error
Event Source: xxxx
Event Category: None
Event ID: 100
Date: 31/08/2006
Time: 15:50:13
User: N/A
Computer: my pc
Description:
Timestamp: 31/08/2006 14:50:13
Message: HandlingInstanceID: b7b8de29-ed22-425e-a240-3ed4d92e8de4
An exception of type 'System.InvalidProgramException' occurred and was caught.
08/31/2006 15:50:13
Type : System.InvalidProgramException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Common Language Runtime detected an invalid program.
Source : MyCompany.Messaging.Channels
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : Void ListenForMessages()
Stack Trace : at MyCompany.Messaging.Channels.SqlServiceBrokerUtility.ListenForMessages()
at MyCompany.Messaging.Channels.SqlServiceBrokerUtility.StartListeningForMessages() in xxxxxxxxx\MyCompany.Messaging.Channels\SqlServiceBrokerUtility.vb:line 230
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Additional Info:
MachineName : xxx
TimeStamp : 31/08/2006 14:50:13
FullName : Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null
AppDomainName : MyCompany.Integration.Host.Console.exe
ThreadIdentity :
WindowsIdentity : MyCompany\xxxxxx
Category: Errors
Priority: 0
EventId: 100
Severity: Error
Title:cccc
Machine: xxxx
Application Domain: MyCompany.Integration.Host.Console.exe
Process Id: 616
Process Name: xxxxxxx\Source\MyCompany.Integration.Host.Console\bin\Debug\MyCompany.Integration.Host.Console.exe
Win32 Thread Id: 2976
Thread Name:
Extended Properties:
After a little exploration, I found that is *only* occurs if I declare IDbConnection or SqlConnection. If I remove any references to these it behaves well.
I've tried everything I know how to in order to make this run under your profiler, but so far no joy.
Perhaps this is something seen before?
Unfortunately I won't be able to provider any source code. Maybe tonight after work I will try and create a project which will repro this.
Cheers,
Paul
When I profile my application with the performance profiler, it consistantly fails with a System.InvalidProgramException.
I've searched around for this on Google, and various articles suggest that it is related to bad MSIL. The same application works perfectly well under the memory profiler, and opened directly (as console app).
The crash log gives the error below (I've blanked out the company in the namespace)
Event Type: Error
Event Source: .NET Runtime 2.0 Error Reporting
Event Category: None
Event ID: 5000
Date: 31/08/2006
Time: 15:08:25
User: N/A
Computer: MYPC
Description:
EventType clr20r3, P1 utimydz5wtxl4ptvworcggqxpuyxbisk, P2 1.0.0.0, P3 44f6ed23, P4 companyx.messaging.channels, P5 1.0.0.0, P6 44f6ed19, P7 7e, P8 3e, P9 system.invalidprogramexception, P10 NIL.
My own exception handler captures the following:
Event Type: Error
Event Source: xxxx
Event Category: None
Event ID: 100
Date: 31/08/2006
Time: 15:50:13
User: N/A
Computer: my pc
Description:
Timestamp: 31/08/2006 14:50:13
Message: HandlingInstanceID: b7b8de29-ed22-425e-a240-3ed4d92e8de4
An exception of type 'System.InvalidProgramException' occurred and was caught.
08/31/2006 15:50:13
Type : System.InvalidProgramException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Common Language Runtime detected an invalid program.
Source : MyCompany.Messaging.Channels
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : Void ListenForMessages()
Stack Trace : at MyCompany.Messaging.Channels.SqlServiceBrokerUtility.ListenForMessages()
at MyCompany.Messaging.Channels.SqlServiceBrokerUtility.StartListeningForMessages() in xxxxxxxxx\MyCompany.Messaging.Channels\SqlServiceBrokerUtility.vb:line 230
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Additional Info:
MachineName : xxx
TimeStamp : 31/08/2006 14:50:13
FullName : Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null
AppDomainName : MyCompany.Integration.Host.Console.exe
ThreadIdentity :
WindowsIdentity : MyCompany\xxxxxx
Category: Errors
Priority: 0
EventId: 100
Severity: Error
Title:cccc
Machine: xxxx
Application Domain: MyCompany.Integration.Host.Console.exe
Process Id: 616
Process Name: xxxxxxx\Source\MyCompany.Integration.Host.Console\bin\Debug\MyCompany.Integration.Host.Console.exe
Win32 Thread Id: 2976
Thread Name:
Extended Properties:
After a little exploration, I found that is *only* occurs if I declare IDbConnection or SqlConnection. If I remove any references to these it behaves well.
I've tried everything I know how to in order to make this run under your profiler, but so far no joy.
Perhaps this is something seen before?
Unfortunately I won't be able to provider any source code. Maybe tonight after work I will try and create a project which will repro this.
Cheers,
Paul
Comments
this has come up 2 or 3 times now, but no one has been able to create us a small test app. I'd be delighted if you knock one up for us - maybe a free copy of the profiler if you can!
Many thanks,
Tom Harris
Red Gate Software Ltd
For us, it always is happening when we copy a generic list to an array, so I'm wondering if that's the same for you, or if it's 2 seperate issues in the profiler.
Cheers,
Paul
I suspect that the two problems are the same or related. Many thanks for putting in the extra effort to try and create a sample for us. We will definitely go ahead and fix it once we can spot what is going wrong.
Keep up the good work,
Tom Harris
Red Gate Software
Running version 2.7.1.20.
The exception handler captures this information:
If you'd like, I can try to distill this problem into a test project.
a test application would be great. We have a sample in VB.NET, but not C#. The problem always seems to occur with generic lists of different value types (e.g int's and bool's), but we have not got to the bottom of it yet.
Best regards,
Tom Harris
Red Gate Software
I'll look into creating a test project shortly.
Remove the marked line and the profiler does not crash. I hope this helps you narrow down the problem.
One other note: In my efforts to narrow this down I copied the code for the above class to a test project. The identical code had absolutely no problems running there! Thinking it was related to referenced projects, I created a separate library and placed a copy of this code in it, and still there were no problems.
Here's the repro test case: Bad Class Token repro test case.zip
p.s. Tom, I'll take you up on that free Ants Profiler offer. :-)
thanks for all your time on this one. Something odd is clearly going on. I am able to succesfully profile the performance of your app fine with AP 2.7.1.20.
I have not recompiled on my machine, but simply profiled the binaries you sent. I'm running XP SP2.
Am I missing something, or can you think of anything special that you are doing?
Regards,
Tom
Thanks,
Tom Harris
Red Gate Software
We had this issue in 2.7 and believed it would be fixed for 3. Having the issue means that we cannot use ANTS.
I've just upgraded to 3.0 specifically for the resolution to this issue, but I am still having the problem.
Any ideas ?
Glen
We fixed all the cases we could reproduce here in V3.
One think you might wish to try is profiling in fast mode instead of detailed mode - do you still see the problem? If not, then it narrows it down to a smaller set of things that could be causing it.
Do you think it would be possible to send us a copy of an application that exhibits this bug? We don't need the source code, just the application and associated PDB (and any libraries needed to get the thing to run).
Alternatively, if you can come up with a small test case that fails, that'd be even better! I dare say if you can help us out here then a free ANTS Profiler T-shirt would be in order...
Thanks,
Rob
Red Gate