简体   繁体   English

如何使.NET 4抛出ExecutionEngineException?

[英]How to cause .NET 4 to throw ExecutionEngineException?

We have a situation where our application sometimes raises an ExecutionEngineException . 我们的应用程序有时会引发ExecutionEngineException I thought that when it happens, the application should crash, but it does not crash. 我认为当它发生时,应用程序应该崩溃,但它不会崩溃。 And even if the event viewer claims that the application was terminated - it continues running! 即使事件查看器声称应用程序已终止 - 它仍继续运行! Only seems that the offending thread is silently killed. 只是看起来有问题的线程被静默杀死。

The problem is that we are unable to recreate the conditions when it occurs - the suspected code is executed thousands of times before the exception occurs. 问题是我们无法在发生时重新创建条件 - 可疑代码在异常发生之前执行了数千次。 There is nothing in the logs. 日志中没有任何内容。 In short - we are puzzled. 简而言之 - 我们感到困惑。

I would like to be able to generate this exception at will in order to learn how our application behaves when it happens. 我希望能够随意生成此异常,以便了解应用程序在发生时的行为方式。 Of course, it must be thrown by the framework itself, issuing throw new ExecutionEngineException does not count. 当然,它必须由框架本身throw new ExecutionEngineExceptionthrow new ExecutionEngineException不计算。

So, my question is - how can I cause it reliably? 所以,我的问题是 - 我怎样才能可靠地引起它? Please, provide a code sample. 请提供代码示例。

We are on .NET 4, moving soon to .NET 4.5 我们在.NET 4上,很快就转向.NET 4.5

From the MSDN documentation : MSDN文档

In some cases, an application that targets the .NET Framework may throw an ExecutionEngineException exception during garbage collection when an application or the system on which it is running is under a heavy load. 在某些情况下,当应用程序或运行它的系统负载很重时,以.NET Framework为目标的应用程序可能会在垃圾回收期间抛出ExecutionEngineException异常。 In this case, To work around this issue, you can disable concurrent garbage collection by modifying the application's configuration file. 在这种情况下,要解决此问题,可以通过修改应用程序的配置文件来禁用并发垃圾回收。 For more information, see How to: Disable Concurrent Garbage Collection . 有关更多信息,请参见如何:禁用并发垃圾收集

In case the workaround suggested by the MSDN documentation doesn't work for you, you will have to test based on what you know about your software. 如果MSDN文档建议的解决方法不适合您,则必须根据您对软件的了解进行测试。

Now, creating a test application that simulates load, multi-thread behaviour and memory consumption of your real application is one thing - it is probably better to use the actual software as test software (perhaps augmented with some additional debug-logging + test code). 现在,创建一个模拟真实应用程序的负载,多线程行为和内存消耗的测试应用程序是一回事 - 使用实际软件作为测试软件可能更好(可能增加了一些额外的调试日志+测试代码) 。 That means, unfortunately no code sample here :( 这意味着,遗憾的是这里没有代码示例:(

To make the load tests meaningful, you would also need to run these tests on a test system that has a very similar, if not identical hardware/software configuration as your production system. 要使负载测试有意义,您还需要在测试系统上运行这些测试,该测试系统具有与生产系统非常相似(如果不是相同的)硬件/软件配置。 And only then you will be able to find out if your ExecutionEngineException is caused by the GC or by an otherwise corrupted runtime. 只有这样,您才能确定您的ExecutionEngineException是由GC还是由其他损坏的运行时引起的。

You cannot cause ExecutionEngineException easily unless you reproduce the issue (even if you have to do that in production environment). 除非重现问题(即使必须在生产环境中执行此操作),否则不能轻易导致ExecutionEngineException。 Microsoft has utilities such as DebugDiag that can help you capture full memory dumps when such exceptions occur, Microsoft具有DebugDiag等实用程序,可以帮助您在发生此类异常时捕获完整的内存转储,

http://blogs.msdn.com/b/chaun/archive/2013/09/15/steps-to-trigger-a-user-dump-of-a-process-with-debugdiag-1-2-when-a-specific-net-exception-is-thrown.aspx http://blogs.msdn.com/b/chaun/archive/2013/09/15/steps-to-trigger-a-user-dump-of-a-process-with-debugdiag-1-2-when-一个特定的净例外是,thrown.aspx

and via dump analysis it is easy to locate the culprit. 通过转储分析,很容易找到罪魁祸首。 Don't expect your logs can tell, as when this exception occurs the CLR crashes, and your logs never go that deep. 不要指望你的日志可以告诉你,因为当这个异常发生时CLR崩溃,你的日志永远不会那么深。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是什么原因导致此ExecutionEngineException? - What might cause this ExecutionEngineException? 为什么带有嵌套数组的Marshal.PtrToStructure抛出ExecutionEngineException? - Why does Marshal.PtrToStructure with nested arrays throw an ExecutionEngineException? 为什么尝试的 Union 结构会导致 System.ExecutionEngineException? - Why does attempted Union structure cause System.ExecutionEngineException? 为什么并发GC有时会导致ExecutionEngineException(每个MSDN)? - Why does concurrent GC sometimes cause ExecutionEngineException (per MSDN)? 如何在.net WebService中抛出SoapFault? - How to throw SoapFault in .net WebService? 如何在.Net中检测拳击原因? - How to detect cause of boxing in .Net? 将接口数组从.Net编组到C ++时引发ExecutionEngineException - ExecutionEngineException thrown when marshalling interface array from .Net to C++ 如何找到.NET中阻止终结器的原因? - How to find the cause of blocking finalizer in .NET? 如何在.net应用程序中查找内存泄漏的原因 - How to find the cause of a memory leak in a .net application 我如何找到导致null异常的原因? 我的意思是异常抛出哪行或在代码中的何处? - How can i find what cause a null exception ? I mean what line or where in the code the exception throw?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM